Skip to content

Commit 278a8fc

Browse files
feat: add repositoryevent to buildtrigger (#409)
* feat: add repositoryevent to buildtrigger PiperOrigin-RevId: 543799743 Source-Link: googleapis/googleapis@7972185 Source-Link: googleapis/googleapis-gen@137bb03 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTM3YmIwMzcyNTc1YTY2YzNiMWFlNzBhNjE1YzA2NzllZmIxMGI0YyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 5bf6d23 commit 278a8fc

9 files changed

Lines changed: 203 additions & 38 deletions

File tree

packages/google-cloud-build/google/cloud/devtools/cloudbuild/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import (
8282
ReceiveTriggerWebhookResponse,
8383
)
84+
from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import RepositoryEventConfig
8485
from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import RepoSource
8586
from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import Results
8687
from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import RetryBuildRequest
@@ -150,6 +151,7 @@
150151
"PushFilter",
151152
"ReceiveTriggerWebhookRequest",
152153
"ReceiveTriggerWebhookResponse",
154+
"RepositoryEventConfig",
153155
"RepoSource",
154156
"Results",
155157
"RetryBuildRequest",

packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
from .types.cloudbuild import PushFilter
6262
from .types.cloudbuild import ReceiveTriggerWebhookRequest
6363
from .types.cloudbuild import ReceiveTriggerWebhookResponse
64+
from .types.cloudbuild import RepositoryEventConfig
6465
from .types.cloudbuild import RepoSource
6566
from .types.cloudbuild import Results
6667
from .types.cloudbuild import RetryBuildRequest
@@ -127,6 +128,7 @@
127128
"ReceiveTriggerWebhookRequest",
128129
"ReceiveTriggerWebhookResponse",
129130
"RepoSource",
131+
"RepositoryEventConfig",
130132
"Results",
131133
"RetryBuildRequest",
132134
"RunBuildTriggerRequest",

packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/async_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class CloudBuildAsyncClient:
7979
parse_crypto_key_path = staticmethod(CloudBuildClient.parse_crypto_key_path)
8080
network_path = staticmethod(CloudBuildClient.network_path)
8181
parse_network_path = staticmethod(CloudBuildClient.parse_network_path)
82+
repository_path = staticmethod(CloudBuildClient.repository_path)
83+
parse_repository_path = staticmethod(CloudBuildClient.parse_repository_path)
8284
secret_version_path = staticmethod(CloudBuildClient.secret_version_path)
8385
parse_secret_version_path = staticmethod(CloudBuildClient.parse_secret_version_path)
8486
service_account_path = staticmethod(CloudBuildClient.service_account_path)

packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/client.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,30 @@ def parse_network_path(path: str) -> Dict[str, str]:
265265
)
266266
return m.groupdict() if m else {}
267267

268+
@staticmethod
269+
def repository_path(
270+
project: str,
271+
location: str,
272+
connection: str,
273+
repository: str,
274+
) -> str:
275+
"""Returns a fully-qualified repository string."""
276+
return "projects/{project}/locations/{location}/connections/{connection}/repositories/{repository}".format(
277+
project=project,
278+
location=location,
279+
connection=connection,
280+
repository=repository,
281+
)
282+
283+
@staticmethod
284+
def parse_repository_path(path: str) -> Dict[str, str]:
285+
"""Parses a repository path into its component segments."""
286+
m = re.match(
287+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/connections/(?P<connection>.+?)/repositories/(?P<repository>.+?)$",
288+
path,
289+
)
290+
return m.groupdict() if m else {}
291+
268292
@staticmethod
269293
def secret_version_path(
270294
project: str,

packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
PushFilter,
5555
ReceiveTriggerWebhookRequest,
5656
ReceiveTriggerWebhookResponse,
57+
RepositoryEventConfig,
5758
RepoSource,
5859
Results,
5960
RetryBuildRequest,
@@ -118,6 +119,7 @@
118119
"PushFilter",
119120
"ReceiveTriggerWebhookRequest",
120121
"ReceiveTriggerWebhookResponse",
122+
"RepositoryEventConfig",
121123
"RepoSource",
122124
"Results",
123125
"RetryBuildRequest",

packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"ApprovalConfig",
6565
"ApprovalResult",
6666
"BuildTrigger",
67+
"RepositoryEventConfig",
6768
"GitHubEventsConfig",
6869
"PubsubConfig",
6970
"WebhookConfig",
@@ -2195,6 +2196,10 @@ class BuildTrigger(proto.Message):
21952196
([PROJECT_NUM]@system.gserviceaccount.com) will be used
21962197
instead. Format:
21972198
``projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT_ID_OR_EMAIL}``
2199+
repository_event_config (google.cloud.devtools.cloudbuild_v1.types.RepositoryEventConfig):
2200+
The configuration of a trigger that creates a
2201+
build whenever an event from Repo API is
2202+
received.
21982203
"""
21992204

22002205
resource_name: str = proto.Field(
@@ -2283,6 +2288,81 @@ class BuildTrigger(proto.Message):
22832288
proto.STRING,
22842289
number=33,
22852290
)
2291+
repository_event_config: "RepositoryEventConfig" = proto.Field(
2292+
proto.MESSAGE,
2293+
number=39,
2294+
message="RepositoryEventConfig",
2295+
)
2296+
2297+
2298+
class RepositoryEventConfig(proto.Message):
2299+
r"""The configuration of a trigger that creates a build whenever
2300+
an event from Repo API is received.
2301+
2302+
This message has `oneof`_ fields (mutually exclusive fields).
2303+
For each oneof, at most one member field can be set at the same time.
2304+
Setting any member of the oneof automatically clears all other
2305+
members.
2306+
2307+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
2308+
2309+
Attributes:
2310+
repository (str):
2311+
The resource name of the Repo API resource.
2312+
repository_type (google.cloud.devtools.cloudbuild_v1.types.RepositoryEventConfig.RepositoryType):
2313+
Output only. The type of the SCM vendor the
2314+
repository points to.
2315+
pull_request (google.cloud.devtools.cloudbuild_v1.types.PullRequestFilter):
2316+
Filter to match changes in pull requests.
2317+
2318+
This field is a member of `oneof`_ ``filter``.
2319+
push (google.cloud.devtools.cloudbuild_v1.types.PushFilter):
2320+
Filter to match changes in refs like
2321+
branches, tags.
2322+
2323+
This field is a member of `oneof`_ ``filter``.
2324+
"""
2325+
2326+
class RepositoryType(proto.Enum):
2327+
r"""All possible SCM repo types from Repo API.
2328+
2329+
Values:
2330+
REPOSITORY_TYPE_UNSPECIFIED (0):
2331+
If unspecified, RepositoryType defaults to
2332+
GITHUB.
2333+
GITHUB (1):
2334+
The SCM repo is GITHUB.
2335+
GITHUB_ENTERPRISE (2):
2336+
The SCM repo is GITHUB Enterprise.
2337+
GITLAB_ENTERPRISE (3):
2338+
The SCM repo is GITLAB Enterprise.
2339+
"""
2340+
REPOSITORY_TYPE_UNSPECIFIED = 0
2341+
GITHUB = 1
2342+
GITHUB_ENTERPRISE = 2
2343+
GITLAB_ENTERPRISE = 3
2344+
2345+
repository: str = proto.Field(
2346+
proto.STRING,
2347+
number=1,
2348+
)
2349+
repository_type: RepositoryType = proto.Field(
2350+
proto.ENUM,
2351+
number=2,
2352+
enum=RepositoryType,
2353+
)
2354+
pull_request: "PullRequestFilter" = proto.Field(
2355+
proto.MESSAGE,
2356+
number=3,
2357+
oneof="filter",
2358+
message="PullRequestFilter",
2359+
)
2360+
push: "PushFilter" = proto.Field(
2361+
proto.MESSAGE,
2362+
number=4,
2363+
oneof="filter",
2364+
message="PushFilter",
2365+
)
22862366

22872367

22882368
class GitHubEventsConfig(proto.Message):

packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-build",
11-
"version": "3.16.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-build",
11-
"version": "3.16.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

0 commit comments

Comments
 (0)