Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
feat: Add GitLabConfig and fetchGitRefs for Cloud Build Repositories (#…
Browse files Browse the repository at this point in the history
…412)

* feat: Add GitLabConfig and fetchGitRefs for Cloud Build Repositories

PiperOrigin-RevId: 544132349

Source-Link: googleapis/googleapis@f006f7f

Source-Link: googleapis/googleapis-gen@c5e33e0
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzVlMzNlMGFkYjE2MTUzNjQ5MTNjODUyOTNhZGFjY2RmMzY4ZjAwZSJ9

* 🦉 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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Jun 29, 2023
1 parent 6716655 commit f5b1b42
Show file tree
Hide file tree
Showing 15 changed files with 1,478 additions and 5 deletions.
10 changes: 10 additions & 0 deletions google/cloud/devtools/cloudbuild_v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from .types.repositories import CreateRepositoryRequest
from .types.repositories import DeleteConnectionRequest
from .types.repositories import DeleteRepositoryRequest
from .types.repositories import FetchGitRefsRequest
from .types.repositories import FetchGitRefsResponse
from .types.repositories import FetchLinkableRepositoriesRequest
from .types.repositories import FetchLinkableRepositoriesResponse
from .types.repositories import FetchReadTokenRequest
Expand All @@ -40,15 +42,18 @@
from .types.repositories import GetRepositoryRequest
from .types.repositories import GitHubConfig
from .types.repositories import GitHubEnterpriseConfig
from .types.repositories import GitLabConfig
from .types.repositories import InstallationState
from .types.repositories import ListConnectionsRequest
from .types.repositories import ListConnectionsResponse
from .types.repositories import ListRepositoriesRequest
from .types.repositories import ListRepositoriesResponse
from .types.repositories import OAuthCredential
from .types.repositories import ProcessWebhookRequest
from .types.repositories import Repository
from .types.repositories import ServiceDirectoryConfig
from .types.repositories import UpdateConnectionRequest
from .types.repositories import UserCredential

__all__ = (
"RepositoryManagerAsyncClient",
Expand All @@ -59,6 +64,8 @@
"CreateRepositoryRequest",
"DeleteConnectionRequest",
"DeleteRepositoryRequest",
"FetchGitRefsRequest",
"FetchGitRefsResponse",
"FetchLinkableRepositoriesRequest",
"FetchLinkableRepositoriesResponse",
"FetchReadTokenRequest",
Expand All @@ -69,16 +76,19 @@
"GetRepositoryRequest",
"GitHubConfig",
"GitHubEnterpriseConfig",
"GitLabConfig",
"InstallationState",
"ListConnectionsRequest",
"ListConnectionsResponse",
"ListRepositoriesRequest",
"ListRepositoriesResponse",
"OAuthCredential",
"OperationMetadata",
"ProcessWebhookRequest",
"Repository",
"RepositoryManagerClient",
"RunWorkflowCustomOperationMetadata",
"ServiceDirectoryConfig",
"UpdateConnectionRequest",
"UserCredential",
)
15 changes: 15 additions & 0 deletions google/cloud/devtools/cloudbuild_v2/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
"delete_repository"
]
},
"FetchGitRefs": {
"methods": [
"fetch_git_refs"
]
},
"FetchLinkableRepositories": {
"methods": [
"fetch_linkable_repositories"
Expand Down Expand Up @@ -105,6 +110,11 @@
"delete_repository"
]
},
"FetchGitRefs": {
"methods": [
"fetch_git_refs"
]
},
"FetchLinkableRepositories": {
"methods": [
"fetch_linkable_repositories"
Expand Down Expand Up @@ -175,6 +185,11 @@
"delete_repository"
]
},
"FetchGitRefs": {
"methods": [
"fetch_git_refs"
]
},
"FetchLinkableRepositories": {
"methods": [
"fetch_linkable_repositories"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@


class RepositoryManagerAsyncClient:
"""Manages connections to source code repostiories."""
"""Manages connections to source code repositories."""

_client: RepositoryManagerClient

Expand Down Expand Up @@ -1828,6 +1828,109 @@ async def sample_fetch_linkable_repositories():
# Done; return the response.
return response

async def fetch_git_refs(
self,
request: Optional[Union[repositories.FetchGitRefsRequest, dict]] = None,
*,
repository: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> repositories.FetchGitRefsResponse:
r"""Fetch the list of branches or tags for a given
repository.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud.devtools import cloudbuild_v2
async def sample_fetch_git_refs():
# Create a client
client = cloudbuild_v2.RepositoryManagerAsyncClient()
# Initialize request argument(s)
request = cloudbuild_v2.FetchGitRefsRequest(
repository="repository_value",
)
# Make the request
response = await client.fetch_git_refs(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.devtools.cloudbuild_v2.types.FetchGitRefsRequest, dict]]):
The request object. Request for fetching git refs
repository (:class:`str`):
Required. The resource name of the repository in the
format
``projects/*/locations/*/connections/*/repositories/*``.
This corresponds to the ``repository`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.cloud.devtools.cloudbuild_v2.types.FetchGitRefsResponse:
Response for fetching git refs
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([repository])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

request = repositories.FetchGitRefsRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if repository is not None:
request.repository = repository

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.fetch_git_refs,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("repository", request.repository),)
),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def get_operation(
self,
request: Optional[operations_pb2.GetOperationRequest] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def get_transport_class(


class RepositoryManagerClient(metaclass=RepositoryManagerClientMeta):
"""Manages connections to source code repostiories."""
"""Manages connections to source code repositories."""

@staticmethod
def _get_default_mtls_endpoint(api_endpoint):
Expand Down Expand Up @@ -2063,6 +2063,109 @@ def sample_fetch_linkable_repositories():
# Done; return the response.
return response

def fetch_git_refs(
self,
request: Optional[Union[repositories.FetchGitRefsRequest, dict]] = None,
*,
repository: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> repositories.FetchGitRefsResponse:
r"""Fetch the list of branches or tags for a given
repository.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud.devtools import cloudbuild_v2
def sample_fetch_git_refs():
# Create a client
client = cloudbuild_v2.RepositoryManagerClient()
# Initialize request argument(s)
request = cloudbuild_v2.FetchGitRefsRequest(
repository="repository_value",
)
# Make the request
response = client.fetch_git_refs(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.devtools.cloudbuild_v2.types.FetchGitRefsRequest, dict]):
The request object. Request for fetching git refs
repository (str):
Required. The resource name of the repository in the
format
``projects/*/locations/*/connections/*/repositories/*``.
This corresponds to the ``repository`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.cloud.devtools.cloudbuild_v2.types.FetchGitRefsResponse:
Response for fetching git refs
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([repository])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# Minor optimization to avoid making a copy if the user passes
# in a repositories.FetchGitRefsRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, repositories.FetchGitRefsRequest):
request = repositories.FetchGitRefsRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if repository is not None:
request.repository = repository

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.fetch_git_refs]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("repository", request.repository),)
),
)

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

def __enter__(self) -> "RepositoryManagerClient":
return self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=60.0,
client_info=client_info,
),
self.fetch_git_refs: gapic_v1.method.wrap_method(
self.fetch_git_refs,
default_timeout=None,
client_info=client_info,
),
}

def close(self):
Expand Down Expand Up @@ -405,6 +410,18 @@ def fetch_linkable_repositories(
]:
raise NotImplementedError()

@property
def fetch_git_refs(
self,
) -> Callable[
[repositories.FetchGitRefsRequest],
Union[
repositories.FetchGitRefsResponse,
Awaitable[repositories.FetchGitRefsResponse],
],
]:
raise NotImplementedError()

@property
def get_operation(
self,
Expand Down
Loading

0 comments on commit f5b1b42

Please sign in to comment.