diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager/__init__.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager/__init__.py index 0596a51c6e12..fd51d329d895 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager/__init__.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager/__init__.py @@ -25,49 +25,157 @@ SecureSourceManagerClient, ) from google.cloud.securesourcemanager_v1.types.secure_source_manager import ( + BatchCreatePullRequestCommentsRequest, + BatchCreatePullRequestCommentsResponse, BranchRule, + CloseIssueRequest, + ClosePullRequestRequest, CreateBranchRuleRequest, + CreateHookRequest, CreateInstanceRequest, + CreateIssueCommentRequest, + CreateIssueRequest, + CreatePullRequestCommentRequest, + CreatePullRequestRequest, CreateRepositoryRequest, DeleteBranchRuleRequest, + DeleteHookRequest, DeleteInstanceRequest, + DeleteIssueCommentRequest, + DeleteIssueRequest, + DeletePullRequestCommentRequest, DeleteRepositoryRequest, + FetchBlobRequest, + FetchBlobResponse, + FetchTreeRequest, + FetchTreeResponse, + FileDiff, GetBranchRuleRequest, + GetHookRequest, GetInstanceRequest, + GetIssueCommentRequest, + GetIssueRequest, + GetPullRequestCommentRequest, + GetPullRequestRequest, GetRepositoryRequest, + Hook, Instance, + Issue, + IssueComment, ListBranchRulesRequest, ListBranchRulesResponse, + ListHooksRequest, + ListHooksResponse, ListInstancesRequest, ListInstancesResponse, + ListIssueCommentsRequest, + ListIssueCommentsResponse, + ListIssuesRequest, + ListIssuesResponse, + ListPullRequestCommentsRequest, + ListPullRequestCommentsResponse, + ListPullRequestFileDiffsRequest, + ListPullRequestFileDiffsResponse, + ListPullRequestsRequest, + ListPullRequestsResponse, ListRepositoriesRequest, ListRepositoriesResponse, + MergePullRequestRequest, + OpenIssueRequest, + OpenPullRequestRequest, OperationMetadata, + PullRequest, + PullRequestComment, Repository, + ResolvePullRequestCommentsRequest, + ResolvePullRequestCommentsResponse, + TreeEntry, + UnresolvePullRequestCommentsRequest, + UnresolvePullRequestCommentsResponse, UpdateBranchRuleRequest, + UpdateHookRequest, + UpdateIssueCommentRequest, + UpdateIssueRequest, + UpdatePullRequestCommentRequest, + UpdatePullRequestRequest, + UpdateRepositoryRequest, ) __all__ = ( "SecureSourceManagerClient", "SecureSourceManagerAsyncClient", + "BatchCreatePullRequestCommentsRequest", + "BatchCreatePullRequestCommentsResponse", "BranchRule", + "CloseIssueRequest", + "ClosePullRequestRequest", "CreateBranchRuleRequest", + "CreateHookRequest", "CreateInstanceRequest", + "CreateIssueCommentRequest", + "CreateIssueRequest", + "CreatePullRequestCommentRequest", + "CreatePullRequestRequest", "CreateRepositoryRequest", "DeleteBranchRuleRequest", + "DeleteHookRequest", "DeleteInstanceRequest", + "DeleteIssueCommentRequest", + "DeleteIssueRequest", + "DeletePullRequestCommentRequest", "DeleteRepositoryRequest", + "FetchBlobRequest", + "FetchBlobResponse", + "FetchTreeRequest", + "FetchTreeResponse", + "FileDiff", "GetBranchRuleRequest", + "GetHookRequest", "GetInstanceRequest", + "GetIssueCommentRequest", + "GetIssueRequest", + "GetPullRequestCommentRequest", + "GetPullRequestRequest", "GetRepositoryRequest", + "Hook", "Instance", + "Issue", + "IssueComment", "ListBranchRulesRequest", "ListBranchRulesResponse", + "ListHooksRequest", + "ListHooksResponse", "ListInstancesRequest", "ListInstancesResponse", + "ListIssueCommentsRequest", + "ListIssueCommentsResponse", + "ListIssuesRequest", + "ListIssuesResponse", + "ListPullRequestCommentsRequest", + "ListPullRequestCommentsResponse", + "ListPullRequestFileDiffsRequest", + "ListPullRequestFileDiffsResponse", + "ListPullRequestsRequest", + "ListPullRequestsResponse", "ListRepositoriesRequest", "ListRepositoriesResponse", + "MergePullRequestRequest", + "OpenIssueRequest", + "OpenPullRequestRequest", "OperationMetadata", + "PullRequest", + "PullRequestComment", "Repository", + "ResolvePullRequestCommentsRequest", + "ResolvePullRequestCommentsResponse", + "TreeEntry", + "UnresolvePullRequestCommentsRequest", + "UnresolvePullRequestCommentsResponse", "UpdateBranchRuleRequest", + "UpdateHookRequest", + "UpdateIssueCommentRequest", + "UpdateIssueRequest", + "UpdatePullRequestCommentRequest", + "UpdatePullRequestRequest", + "UpdateRepositoryRequest", ) diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/__init__.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/__init__.py index d37837c1be30..8f03232b381c 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/__init__.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/__init__.py @@ -23,49 +23,157 @@ SecureSourceManagerClient, ) from .types.secure_source_manager import ( + BatchCreatePullRequestCommentsRequest, + BatchCreatePullRequestCommentsResponse, BranchRule, + CloseIssueRequest, + ClosePullRequestRequest, CreateBranchRuleRequest, + CreateHookRequest, CreateInstanceRequest, + CreateIssueCommentRequest, + CreateIssueRequest, + CreatePullRequestCommentRequest, + CreatePullRequestRequest, CreateRepositoryRequest, DeleteBranchRuleRequest, + DeleteHookRequest, DeleteInstanceRequest, + DeleteIssueCommentRequest, + DeleteIssueRequest, + DeletePullRequestCommentRequest, DeleteRepositoryRequest, + FetchBlobRequest, + FetchBlobResponse, + FetchTreeRequest, + FetchTreeResponse, + FileDiff, GetBranchRuleRequest, + GetHookRequest, GetInstanceRequest, + GetIssueCommentRequest, + GetIssueRequest, + GetPullRequestCommentRequest, + GetPullRequestRequest, GetRepositoryRequest, + Hook, Instance, + Issue, + IssueComment, ListBranchRulesRequest, ListBranchRulesResponse, + ListHooksRequest, + ListHooksResponse, ListInstancesRequest, ListInstancesResponse, + ListIssueCommentsRequest, + ListIssueCommentsResponse, + ListIssuesRequest, + ListIssuesResponse, + ListPullRequestCommentsRequest, + ListPullRequestCommentsResponse, + ListPullRequestFileDiffsRequest, + ListPullRequestFileDiffsResponse, + ListPullRequestsRequest, + ListPullRequestsResponse, ListRepositoriesRequest, ListRepositoriesResponse, + MergePullRequestRequest, + OpenIssueRequest, + OpenPullRequestRequest, OperationMetadata, + PullRequest, + PullRequestComment, Repository, + ResolvePullRequestCommentsRequest, + ResolvePullRequestCommentsResponse, + TreeEntry, + UnresolvePullRequestCommentsRequest, + UnresolvePullRequestCommentsResponse, UpdateBranchRuleRequest, + UpdateHookRequest, + UpdateIssueCommentRequest, + UpdateIssueRequest, + UpdatePullRequestCommentRequest, + UpdatePullRequestRequest, + UpdateRepositoryRequest, ) __all__ = ( "SecureSourceManagerAsyncClient", + "BatchCreatePullRequestCommentsRequest", + "BatchCreatePullRequestCommentsResponse", "BranchRule", + "CloseIssueRequest", + "ClosePullRequestRequest", "CreateBranchRuleRequest", + "CreateHookRequest", "CreateInstanceRequest", + "CreateIssueCommentRequest", + "CreateIssueRequest", + "CreatePullRequestCommentRequest", + "CreatePullRequestRequest", "CreateRepositoryRequest", "DeleteBranchRuleRequest", + "DeleteHookRequest", "DeleteInstanceRequest", + "DeleteIssueCommentRequest", + "DeleteIssueRequest", + "DeletePullRequestCommentRequest", "DeleteRepositoryRequest", + "FetchBlobRequest", + "FetchBlobResponse", + "FetchTreeRequest", + "FetchTreeResponse", + "FileDiff", "GetBranchRuleRequest", + "GetHookRequest", "GetInstanceRequest", + "GetIssueCommentRequest", + "GetIssueRequest", + "GetPullRequestCommentRequest", + "GetPullRequestRequest", "GetRepositoryRequest", + "Hook", "Instance", + "Issue", + "IssueComment", "ListBranchRulesRequest", "ListBranchRulesResponse", + "ListHooksRequest", + "ListHooksResponse", "ListInstancesRequest", "ListInstancesResponse", + "ListIssueCommentsRequest", + "ListIssueCommentsResponse", + "ListIssuesRequest", + "ListIssuesResponse", + "ListPullRequestCommentsRequest", + "ListPullRequestCommentsResponse", + "ListPullRequestFileDiffsRequest", + "ListPullRequestFileDiffsResponse", + "ListPullRequestsRequest", + "ListPullRequestsResponse", "ListRepositoriesRequest", "ListRepositoriesResponse", + "MergePullRequestRequest", + "OpenIssueRequest", + "OpenPullRequestRequest", "OperationMetadata", + "PullRequest", + "PullRequestComment", "Repository", + "ResolvePullRequestCommentsRequest", + "ResolvePullRequestCommentsResponse", "SecureSourceManagerClient", + "TreeEntry", + "UnresolvePullRequestCommentsRequest", + "UnresolvePullRequestCommentsResponse", "UpdateBranchRuleRequest", + "UpdateHookRequest", + "UpdateIssueCommentRequest", + "UpdateIssueRequest", + "UpdatePullRequestCommentRequest", + "UpdatePullRequestRequest", + "UpdateRepositoryRequest", ) diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/gapic_metadata.json b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/gapic_metadata.json index 66ffcc653001..f037a162e26e 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/gapic_metadata.json +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/gapic_metadata.json @@ -10,16 +10,56 @@ "grpc": { "libraryClient": "SecureSourceManagerClient", "rpcs": { + "BatchCreatePullRequestComments": { + "methods": [ + "batch_create_pull_request_comments" + ] + }, + "CloseIssue": { + "methods": [ + "close_issue" + ] + }, + "ClosePullRequest": { + "methods": [ + "close_pull_request" + ] + }, "CreateBranchRule": { "methods": [ "create_branch_rule" ] }, + "CreateHook": { + "methods": [ + "create_hook" + ] + }, "CreateInstance": { "methods": [ "create_instance" ] }, + "CreateIssue": { + "methods": [ + "create_issue" + ] + }, + "CreateIssueComment": { + "methods": [ + "create_issue_comment" + ] + }, + "CreatePullRequest": { + "methods": [ + "create_pull_request" + ] + }, + "CreatePullRequestComment": { + "methods": [ + "create_pull_request_comment" + ] + }, "CreateRepository": { "methods": [ "create_repository" @@ -30,21 +70,56 @@ "delete_branch_rule" ] }, + "DeleteHook": { + "methods": [ + "delete_hook" + ] + }, "DeleteInstance": { "methods": [ "delete_instance" ] }, + "DeleteIssue": { + "methods": [ + "delete_issue" + ] + }, + "DeleteIssueComment": { + "methods": [ + "delete_issue_comment" + ] + }, + "DeletePullRequestComment": { + "methods": [ + "delete_pull_request_comment" + ] + }, "DeleteRepository": { "methods": [ "delete_repository" ] }, + "FetchBlob": { + "methods": [ + "fetch_blob" + ] + }, + "FetchTree": { + "methods": [ + "fetch_tree" + ] + }, "GetBranchRule": { "methods": [ "get_branch_rule" ] }, + "GetHook": { + "methods": [ + "get_hook" + ] + }, "GetIamPolicyRepo": { "methods": [ "get_iam_policy_repo" @@ -55,6 +130,26 @@ "get_instance" ] }, + "GetIssue": { + "methods": [ + "get_issue" + ] + }, + "GetIssueComment": { + "methods": [ + "get_issue_comment" + ] + }, + "GetPullRequest": { + "methods": [ + "get_pull_request" + ] + }, + "GetPullRequestComment": { + "methods": [ + "get_pull_request_comment" + ] + }, "GetRepository": { "methods": [ "get_repository" @@ -65,16 +160,66 @@ "list_branch_rules" ] }, + "ListHooks": { + "methods": [ + "list_hooks" + ] + }, "ListInstances": { "methods": [ "list_instances" ] }, + "ListIssueComments": { + "methods": [ + "list_issue_comments" + ] + }, + "ListIssues": { + "methods": [ + "list_issues" + ] + }, + "ListPullRequestComments": { + "methods": [ + "list_pull_request_comments" + ] + }, + "ListPullRequestFileDiffs": { + "methods": [ + "list_pull_request_file_diffs" + ] + }, + "ListPullRequests": { + "methods": [ + "list_pull_requests" + ] + }, "ListRepositories": { "methods": [ "list_repositories" ] }, + "MergePullRequest": { + "methods": [ + "merge_pull_request" + ] + }, + "OpenIssue": { + "methods": [ + "open_issue" + ] + }, + "OpenPullRequest": { + "methods": [ + "open_pull_request" + ] + }, + "ResolvePullRequestComments": { + "methods": [ + "resolve_pull_request_comments" + ] + }, "SetIamPolicyRepo": { "methods": [ "set_iam_policy_repo" @@ -85,26 +230,101 @@ "test_iam_permissions_repo" ] }, + "UnresolvePullRequestComments": { + "methods": [ + "unresolve_pull_request_comments" + ] + }, "UpdateBranchRule": { "methods": [ "update_branch_rule" ] + }, + "UpdateHook": { + "methods": [ + "update_hook" + ] + }, + "UpdateIssue": { + "methods": [ + "update_issue" + ] + }, + "UpdateIssueComment": { + "methods": [ + "update_issue_comment" + ] + }, + "UpdatePullRequest": { + "methods": [ + "update_pull_request" + ] + }, + "UpdatePullRequestComment": { + "methods": [ + "update_pull_request_comment" + ] + }, + "UpdateRepository": { + "methods": [ + "update_repository" + ] } } }, "grpc-async": { "libraryClient": "SecureSourceManagerAsyncClient", "rpcs": { + "BatchCreatePullRequestComments": { + "methods": [ + "batch_create_pull_request_comments" + ] + }, + "CloseIssue": { + "methods": [ + "close_issue" + ] + }, + "ClosePullRequest": { + "methods": [ + "close_pull_request" + ] + }, "CreateBranchRule": { "methods": [ "create_branch_rule" ] }, + "CreateHook": { + "methods": [ + "create_hook" + ] + }, "CreateInstance": { "methods": [ "create_instance" ] }, + "CreateIssue": { + "methods": [ + "create_issue" + ] + }, + "CreateIssueComment": { + "methods": [ + "create_issue_comment" + ] + }, + "CreatePullRequest": { + "methods": [ + "create_pull_request" + ] + }, + "CreatePullRequestComment": { + "methods": [ + "create_pull_request_comment" + ] + }, "CreateRepository": { "methods": [ "create_repository" @@ -115,21 +335,56 @@ "delete_branch_rule" ] }, + "DeleteHook": { + "methods": [ + "delete_hook" + ] + }, "DeleteInstance": { "methods": [ "delete_instance" ] }, + "DeleteIssue": { + "methods": [ + "delete_issue" + ] + }, + "DeleteIssueComment": { + "methods": [ + "delete_issue_comment" + ] + }, + "DeletePullRequestComment": { + "methods": [ + "delete_pull_request_comment" + ] + }, "DeleteRepository": { "methods": [ "delete_repository" ] }, + "FetchBlob": { + "methods": [ + "fetch_blob" + ] + }, + "FetchTree": { + "methods": [ + "fetch_tree" + ] + }, "GetBranchRule": { "methods": [ "get_branch_rule" ] }, + "GetHook": { + "methods": [ + "get_hook" + ] + }, "GetIamPolicyRepo": { "methods": [ "get_iam_policy_repo" @@ -140,6 +395,26 @@ "get_instance" ] }, + "GetIssue": { + "methods": [ + "get_issue" + ] + }, + "GetIssueComment": { + "methods": [ + "get_issue_comment" + ] + }, + "GetPullRequest": { + "methods": [ + "get_pull_request" + ] + }, + "GetPullRequestComment": { + "methods": [ + "get_pull_request_comment" + ] + }, "GetRepository": { "methods": [ "get_repository" @@ -150,16 +425,66 @@ "list_branch_rules" ] }, + "ListHooks": { + "methods": [ + "list_hooks" + ] + }, "ListInstances": { "methods": [ "list_instances" ] }, + "ListIssueComments": { + "methods": [ + "list_issue_comments" + ] + }, + "ListIssues": { + "methods": [ + "list_issues" + ] + }, + "ListPullRequestComments": { + "methods": [ + "list_pull_request_comments" + ] + }, + "ListPullRequestFileDiffs": { + "methods": [ + "list_pull_request_file_diffs" + ] + }, + "ListPullRequests": { + "methods": [ + "list_pull_requests" + ] + }, "ListRepositories": { "methods": [ "list_repositories" ] }, + "MergePullRequest": { + "methods": [ + "merge_pull_request" + ] + }, + "OpenIssue": { + "methods": [ + "open_issue" + ] + }, + "OpenPullRequest": { + "methods": [ + "open_pull_request" + ] + }, + "ResolvePullRequestComments": { + "methods": [ + "resolve_pull_request_comments" + ] + }, "SetIamPolicyRepo": { "methods": [ "set_iam_policy_repo" @@ -170,26 +495,101 @@ "test_iam_permissions_repo" ] }, + "UnresolvePullRequestComments": { + "methods": [ + "unresolve_pull_request_comments" + ] + }, "UpdateBranchRule": { "methods": [ "update_branch_rule" ] + }, + "UpdateHook": { + "methods": [ + "update_hook" + ] + }, + "UpdateIssue": { + "methods": [ + "update_issue" + ] + }, + "UpdateIssueComment": { + "methods": [ + "update_issue_comment" + ] + }, + "UpdatePullRequest": { + "methods": [ + "update_pull_request" + ] + }, + "UpdatePullRequestComment": { + "methods": [ + "update_pull_request_comment" + ] + }, + "UpdateRepository": { + "methods": [ + "update_repository" + ] } } }, "rest": { "libraryClient": "SecureSourceManagerClient", "rpcs": { + "BatchCreatePullRequestComments": { + "methods": [ + "batch_create_pull_request_comments" + ] + }, + "CloseIssue": { + "methods": [ + "close_issue" + ] + }, + "ClosePullRequest": { + "methods": [ + "close_pull_request" + ] + }, "CreateBranchRule": { "methods": [ "create_branch_rule" ] }, + "CreateHook": { + "methods": [ + "create_hook" + ] + }, "CreateInstance": { "methods": [ "create_instance" ] }, + "CreateIssue": { + "methods": [ + "create_issue" + ] + }, + "CreateIssueComment": { + "methods": [ + "create_issue_comment" + ] + }, + "CreatePullRequest": { + "methods": [ + "create_pull_request" + ] + }, + "CreatePullRequestComment": { + "methods": [ + "create_pull_request_comment" + ] + }, "CreateRepository": { "methods": [ "create_repository" @@ -200,21 +600,56 @@ "delete_branch_rule" ] }, + "DeleteHook": { + "methods": [ + "delete_hook" + ] + }, "DeleteInstance": { "methods": [ "delete_instance" ] }, + "DeleteIssue": { + "methods": [ + "delete_issue" + ] + }, + "DeleteIssueComment": { + "methods": [ + "delete_issue_comment" + ] + }, + "DeletePullRequestComment": { + "methods": [ + "delete_pull_request_comment" + ] + }, "DeleteRepository": { "methods": [ "delete_repository" ] }, + "FetchBlob": { + "methods": [ + "fetch_blob" + ] + }, + "FetchTree": { + "methods": [ + "fetch_tree" + ] + }, "GetBranchRule": { "methods": [ "get_branch_rule" ] }, + "GetHook": { + "methods": [ + "get_hook" + ] + }, "GetIamPolicyRepo": { "methods": [ "get_iam_policy_repo" @@ -225,6 +660,26 @@ "get_instance" ] }, + "GetIssue": { + "methods": [ + "get_issue" + ] + }, + "GetIssueComment": { + "methods": [ + "get_issue_comment" + ] + }, + "GetPullRequest": { + "methods": [ + "get_pull_request" + ] + }, + "GetPullRequestComment": { + "methods": [ + "get_pull_request_comment" + ] + }, "GetRepository": { "methods": [ "get_repository" @@ -235,16 +690,66 @@ "list_branch_rules" ] }, + "ListHooks": { + "methods": [ + "list_hooks" + ] + }, "ListInstances": { "methods": [ "list_instances" ] }, + "ListIssueComments": { + "methods": [ + "list_issue_comments" + ] + }, + "ListIssues": { + "methods": [ + "list_issues" + ] + }, + "ListPullRequestComments": { + "methods": [ + "list_pull_request_comments" + ] + }, + "ListPullRequestFileDiffs": { + "methods": [ + "list_pull_request_file_diffs" + ] + }, + "ListPullRequests": { + "methods": [ + "list_pull_requests" + ] + }, "ListRepositories": { "methods": [ "list_repositories" ] }, + "MergePullRequest": { + "methods": [ + "merge_pull_request" + ] + }, + "OpenIssue": { + "methods": [ + "open_issue" + ] + }, + "OpenPullRequest": { + "methods": [ + "open_pull_request" + ] + }, + "ResolvePullRequestComments": { + "methods": [ + "resolve_pull_request_comments" + ] + }, "SetIamPolicyRepo": { "methods": [ "set_iam_policy_repo" @@ -255,10 +760,45 @@ "test_iam_permissions_repo" ] }, + "UnresolvePullRequestComments": { + "methods": [ + "unresolve_pull_request_comments" + ] + }, "UpdateBranchRule": { "methods": [ "update_branch_rule" ] + }, + "UpdateHook": { + "methods": [ + "update_hook" + ] + }, + "UpdateIssue": { + "methods": [ + "update_issue" + ] + }, + "UpdateIssueComment": { + "methods": [ + "update_issue_comment" + ] + }, + "UpdatePullRequest": { + "methods": [ + "update_pull_request" + ] + }, + "UpdatePullRequestComment": { + "methods": [ + "update_pull_request_comment" + ] + }, + "UpdateRepository": { + "methods": [ + "update_repository" + ] } } } diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/async_client.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/async_client.py index 300de7511ffe..424dcde59d72 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/async_client.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/async_client.py @@ -74,29 +74,8 @@ class SecureSourceManagerAsyncClient: """Secure Source Manager API - Access Secure Source Manager instances, resources, and repositories. - - This API is split across two servers: the Control Plane and the Data - Plane. - - Data Plane endpoints are hosted directly by your Secure Source - Manager instance, so you must connect to your instance's API - hostname to access them. The API hostname looks like the following: - - :: - - https://[instance-id]-[project-number]-api.[location].sourcemanager.dev - - For example, - - :: - - https://my-instance-702770452863-api.us-central1.sourcemanager.dev - - Data Plane endpoints are denoted with **Host: Data Plane**. - - All other endpoints are found in the normal Cloud API location, - namely, ``securcesourcemanager.googleapis.com``. + Access Secure Source Manager instances, resources, and + repositories. """ _client: SecureSourceManagerClient @@ -118,8 +97,26 @@ class SecureSourceManagerAsyncClient: parse_crypto_key_path = staticmethod( SecureSourceManagerClient.parse_crypto_key_path ) + hook_path = staticmethod(SecureSourceManagerClient.hook_path) + parse_hook_path = staticmethod(SecureSourceManagerClient.parse_hook_path) instance_path = staticmethod(SecureSourceManagerClient.instance_path) parse_instance_path = staticmethod(SecureSourceManagerClient.parse_instance_path) + issue_path = staticmethod(SecureSourceManagerClient.issue_path) + parse_issue_path = staticmethod(SecureSourceManagerClient.parse_issue_path) + issue_comment_path = staticmethod(SecureSourceManagerClient.issue_comment_path) + parse_issue_comment_path = staticmethod( + SecureSourceManagerClient.parse_issue_comment_path + ) + pull_request_path = staticmethod(SecureSourceManagerClient.pull_request_path) + parse_pull_request_path = staticmethod( + SecureSourceManagerClient.parse_pull_request_path + ) + pull_request_comment_path = staticmethod( + SecureSourceManagerClient.pull_request_comment_path + ) + parse_pull_request_comment_path = staticmethod( + SecureSourceManagerClient.parse_pull_request_comment_path + ) repository_path = staticmethod(SecureSourceManagerClient.repository_path) parse_repository_path = staticmethod( SecureSourceManagerClient.parse_repository_path @@ -874,7 +871,9 @@ async def list_repositories( ) -> pagers.ListRepositoriesAsyncPager: r"""Lists Repositories in a given project and location. - **Host: Data Plane** + The instance field is required in the query parameter + for requests using the + securesourcemanager.googleapis.com endpoint. .. code-block:: python @@ -1002,8 +1001,6 @@ async def get_repository( ) -> secure_source_manager.Repository: r"""Gets metadata of a repository. - **Host: Data Plane** - .. code-block:: python # This snippet has been automatically generated and should be regarded as a @@ -1118,9 +1115,11 @@ async def create_repository( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: - r"""Creates a new repository in a given project and location. - - **Host: Data Plane** + r"""Creates a new repository in a given project and + location. + The Repository.Instance field is required in the request + body for requests using the + securesourcemanager.googleapis.com endpoint. .. code-block:: python @@ -1257,6 +1256,149 @@ async def sample_create_repository(): # Done; return the response. return response + async def update_repository( + self, + request: Optional[ + Union[secure_source_manager.UpdateRepositoryRequest, dict] + ] = None, + *, + repository: Optional[secure_source_manager.Repository] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the metadata of a 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 import securesourcemanager_v1 + + async def sample_update_repository(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.UpdateRepositoryRequest( + ) + + # Make the request + operation = client.update_repository(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.UpdateRepositoryRequest, dict]]): + The request object. UpdateRepositoryRequest is the + request to update a repository. + repository (:class:`google.cloud.securesourcemanager_v1.types.Repository`): + Required. The repository being + updated. + + This corresponds to the ``repository`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Optional. Field mask is used to specify the fields to be + overwritten in the repository resource by the update. + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Repository` + Metadata of a Secure Source Manager repository. + + """ + # 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. + flattened_params = [repository, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.UpdateRepositoryRequest): + request = secure_source_manager.UpdateRepositoryRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if repository is not None: + request.repository = repository + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_repository + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("repository.name", request.repository.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.Repository, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + async def delete_repository( self, request: Optional[ @@ -1270,8 +1412,6 @@ async def delete_repository( ) -> operation_async.AsyncOperation: r"""Deletes a Repository. - **Host: Data Plane** - .. code-block:: python # This snippet has been automatically generated and should be regarded as a @@ -1309,7 +1449,7 @@ async def sample_delete_repository(): name (:class:`str`): Required. Name of the repository to delete. The format is - projects/{project_number}/locations/{location_id}/repositories/{repository_id}. + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1395,16 +1535,16 @@ async def sample_delete_repository(): # Done; return the response. return response - async def get_iam_policy_repo( + async def list_hooks( self, - request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, + request: Optional[Union[secure_source_manager.ListHooksRequest, dict]] = None, *, - resource: Optional[str] = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> policy_pb2.Policy: - r"""Get IAM policy for a repository. + ) -> pagers.ListHooksAsyncPager: + r"""Lists hooks in a given repository. .. code-block:: python @@ -1416,33 +1556,32 @@ async def get_iam_policy_repo( # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - from google.iam.v1 import iam_policy_pb2 # type: ignore - async def sample_get_iam_policy_repo(): + async def sample_list_hooks(): # Create a client client = securesourcemanager_v1.SecureSourceManagerAsyncClient() # Initialize request argument(s) - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", + request = securesourcemanager_v1.ListHooksRequest( + parent="parent_value", ) # Make the request - response = await client.get_iam_policy_repo(request=request) + page_result = client.list_hooks(request=request) # Handle the response - print(response) + async for response in page_result: + print(response) Args: - request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]): - The request object. Request message for ``GetIamPolicy`` method. - resource (:class:`str`): - REQUIRED: The resource for which the - policy is being requested. See the - operation documentation for the - appropriate value for this field. + request (Optional[Union[google.cloud.securesourcemanager_v1.types.ListHooksRequest, dict]]): + The request object. ListHooksRequest is request to list + hooks. + parent (:class:`str`): + Required. Parent value for + ListHooksRequest. - This corresponds to the ``resource`` field + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1454,43 +1593,18 @@ async def sample_get_iam_policy_repo(): be of type `bytes`. Returns: - google.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. - - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. - - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). - - **JSON example:** - - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` - - **YAML example:** - - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` - - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListHooksAsyncPager: + ListHooksResponse is response to list + hooks. + Iterating over this object will yield + results and resolve additional pages + automatically. """ # 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. - flattened_params = [resource] + flattened_params = [parent] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -1500,23 +1614,26 @@ async def sample_get_iam_policy_repo(): "the individual field arguments should be set." ) - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = iam_policy_pb2.GetIamPolicyRequest(**request) - elif not request: - request = iam_policy_pb2.GetIamPolicyRequest(resource=resource) + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.ListHooksRequest): + request = secure_source_manager.ListHooksRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.get_iam_policy_repo + self._client._transport.list_hooks ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -1530,19 +1647,30 @@ async def sample_get_iam_policy_repo(): metadata=metadata, ) + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListHooksAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + # Done; return the response. return response - async def set_iam_policy_repo( + async def get_hook( self, - request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, + request: Optional[Union[secure_source_manager.GetHookRequest, dict]] = None, *, - resource: Optional[str] = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> policy_pb2.Policy: - r"""Set IAM policy on a repository. + ) -> secure_source_manager.Hook: + r"""Gets metadata of a hook. .. code-block:: python @@ -1554,33 +1682,31 @@ async def set_iam_policy_repo( # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - from google.iam.v1 import iam_policy_pb2 # type: ignore - async def sample_set_iam_policy_repo(): + async def sample_get_hook(): # Create a client client = securesourcemanager_v1.SecureSourceManagerAsyncClient() # Initialize request argument(s) - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", + request = securesourcemanager_v1.GetHookRequest( + name="name_value", ) # Make the request - response = await client.set_iam_policy_repo(request=request) + response = await client.get_hook(request=request) # Handle the response print(response) Args: - request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]): - The request object. Request message for ``SetIamPolicy`` method. - resource (:class:`str`): - REQUIRED: The resource for which the - policy is being specified. See the - operation documentation for the - appropriate value for this field. + request (Optional[Union[google.cloud.securesourcemanager_v1.types.GetHookRequest, dict]]): + The request object. GetHookRequest is the request for + getting a hook. + name (:class:`str`): + Required. Name of the hook to retrieve. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/hooks/{hook_id}``. - This corresponds to the ``resource`` field + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1592,43 +1718,4449 @@ async def sample_set_iam_policy_repo(): be of type `bytes`. Returns: - google.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. + google.cloud.securesourcemanager_v1.types.Hook: + Metadata of a Secure Source Manager + Hook. - A Policy is a collection of bindings. A binding binds + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.GetHookRequest): + request = secure_source_manager.GetHookRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.get_hook] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_hook( + self, + request: Optional[Union[secure_source_manager.CreateHookRequest, dict]] = None, + *, + parent: Optional[str] = None, + hook: Optional[secure_source_manager.Hook] = None, + hook_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a new hook in 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 import securesourcemanager_v1 + + async def sample_create_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + hook = securesourcemanager_v1.Hook() + hook.target_uri = "target_uri_value" + + request = securesourcemanager_v1.CreateHookRequest( + parent="parent_value", + hook=hook, + hook_id="hook_id_value", + ) + + # Make the request + operation = client.create_hook(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.CreateHookRequest, dict]]): + The request object. CreateHookRequest is the request for + creating a hook. + parent (:class:`str`): + Required. The repository in which to create the hook. + Values are of the form + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + hook (:class:`google.cloud.securesourcemanager_v1.types.Hook`): + Required. The resource being created. + This corresponds to the ``hook`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + hook_id (:class:`str`): + Required. The ID to use for the hook, + which will become the final component of + the hook's resource name. This value + restricts to lower-case letters, + numbers, and hyphen, with the first + character a letter, the last a letter or + a number, and a 63 character maximum. + + This corresponds to the ``hook_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Hook` + Metadata of a Secure Source Manager Hook. + + """ + # 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. + flattened_params = [parent, hook, hook_id] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.CreateHookRequest): + request = secure_source_manager.CreateHookRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if hook is not None: + request.hook = hook + if hook_id is not None: + request.hook_id = hook_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.create_hook + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.Hook, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_hook( + self, + request: Optional[Union[secure_source_manager.UpdateHookRequest, dict]] = None, + *, + hook: Optional[secure_source_manager.Hook] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the metadata of a hook. + + .. 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 import securesourcemanager_v1 + + async def sample_update_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + hook = securesourcemanager_v1.Hook() + hook.target_uri = "target_uri_value" + + request = securesourcemanager_v1.UpdateHookRequest( + hook=hook, + ) + + # Make the request + operation = client.update_hook(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.UpdateHookRequest, dict]]): + The request object. UpdateHookRequest is the request to + update a hook. + hook (:class:`google.cloud.securesourcemanager_v1.types.Hook`): + Required. The hook being updated. + This corresponds to the ``hook`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Field mask is used to specify the fields to be + overwritten in the hook resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. The special value "*" + means full replacement. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Hook` + Metadata of a Secure Source Manager Hook. + + """ + # 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. + flattened_params = [hook, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.UpdateHookRequest): + request = secure_source_manager.UpdateHookRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if hook is not None: + request.hook = hook + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_hook + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("hook.name", request.hook.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.Hook, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_hook( + self, + request: Optional[Union[secure_source_manager.DeleteHookRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes a Hook. + + .. 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 import securesourcemanager_v1 + + async def sample_delete_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeleteHookRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_hook(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.DeleteHookRequest, dict]]): + The request object. DeleteHookRequest is the request to + delete a hook. + name (:class:`str`): + Required. Name of the hook to delete. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/hooks/{hook_id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.DeleteHookRequest): + request = secure_source_manager.DeleteHookRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.delete_hook + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_iam_policy_repo( + self, + request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, + *, + resource: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> policy_pb2.Policy: + r"""Get IAM policy for a 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 import securesourcemanager_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + async def sample_get_iam_policy_repo(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy_repo(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]): + The request object. Request message for ``GetIamPolicy`` method. + resource (:class:`str`): + REQUIRED: The resource for which the + policy is being requested. See the + operation documentation for the + appropriate value for this field. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.iam.v1.policy_pb2.Policy: + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. + + A Policy is a collection of bindings. A binding binds + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** + + :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + + **YAML example:** + + :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + + For a description of IAM and its features, see the + [IAM + documentation](\ https://cloud.google.com/iam/docs/). + + """ + # 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. + flattened_params = [resource] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = iam_policy_pb2.GetIamPolicyRequest(**request) + elif not request: + request = iam_policy_pb2.GetIamPolicyRequest(resource=resource) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_iam_policy_repo + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def set_iam_policy_repo( + self, + request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, + *, + resource: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> policy_pb2.Policy: + r"""Set IAM policy on a 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 import securesourcemanager_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + async def sample_set_iam_policy_repo(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy_repo(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]): + The request object. Request message for ``SetIamPolicy`` method. + resource (:class:`str`): + REQUIRED: The resource for which the + policy is being specified. See the + operation documentation for the + appropriate value for this field. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.iam.v1.policy_pb2.Policy: + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. + + A Policy is a collection of bindings. A binding binds one or more members, or principals, to a single role. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A role is a named list of permissions; each role can be an IAM predefined role or a user-created custom role. - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** + + :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + + **YAML example:** + + :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + + For a description of IAM and its features, see the + [IAM + documentation](\ https://cloud.google.com/iam/docs/). + + """ + # 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. + flattened_params = [resource] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = iam_policy_pb2.SetIamPolicyRequest(**request) + elif not request: + request = iam_policy_pb2.SetIamPolicyRequest(resource=resource) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.set_iam_policy_repo + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def test_iam_permissions_repo( + self, + request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, + *, + resource: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> iam_policy_pb2.TestIamPermissionsResponse: + r"""Test IAM permissions on a repository. + IAM permission checks are not required on this method. + + .. 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 import securesourcemanager_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + async def sample_test_iam_permissions_repo(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = await client.test_iam_permissions_repo(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]): + The request object. Request message for ``TestIamPermissions`` method. + resource (:class:`str`): + REQUIRED: The resource for which the + policy detail is being requested. See + the operation documentation for the + appropriate value for this field. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: + Response message for TestIamPermissions method. + """ + # 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. + flattened_params = [resource] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = iam_policy_pb2.TestIamPermissionsRequest(**request) + elif not request: + request = iam_policy_pb2.TestIamPermissionsRequest(resource=resource) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.test_iam_permissions_repo + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_branch_rule( + self, + request: Optional[ + Union[secure_source_manager.CreateBranchRuleRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + branch_rule: Optional[secure_source_manager.BranchRule] = None, + branch_rule_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""CreateBranchRule creates a branch rule in 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 import securesourcemanager_v1 + + async def sample_create_branch_rule(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.CreateBranchRuleRequest( + parent="parent_value", + branch_rule_id="branch_rule_id_value", + ) + + # Make the request + operation = client.create_branch_rule(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.CreateBranchRuleRequest, dict]]): + The request object. CreateBranchRuleRequest is the + request to create a branch rule. + parent (:class:`str`): + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + branch_rule (:class:`google.cloud.securesourcemanager_v1.types.BranchRule`): + + This corresponds to the ``branch_rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + branch_rule_id (:class:`str`): + + This corresponds to the ``branch_rule_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.BranchRule` Metadata of a BranchRule. BranchRule is the protection rule to enforce + pre-defined rules on designated branches within a + repository. + + """ + # 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. + flattened_params = [parent, branch_rule, branch_rule_id] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.CreateBranchRuleRequest): + request = secure_source_manager.CreateBranchRuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if branch_rule is not None: + request.branch_rule = branch_rule + if branch_rule_id is not None: + request.branch_rule_id = branch_rule_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.create_branch_rule + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.BranchRule, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_branch_rules( + self, + request: Optional[ + Union[secure_source_manager.ListBranchRulesRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListBranchRulesAsyncPager: + r"""ListBranchRules lists branch rules in 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 import securesourcemanager_v1 + + async def sample_list_branch_rules(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListBranchRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_branch_rules(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.ListBranchRulesRequest, dict]]): + The request object. ListBranchRulesRequest is the request + to list branch rules. + parent (:class:`str`): + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListBranchRulesAsyncPager: + ListBranchRulesResponse is the + response to listing branchRules. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.ListBranchRulesRequest): + request = secure_source_manager.ListBranchRulesRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_branch_rules + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListBranchRulesAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_branch_rule( + self, + request: Optional[ + Union[secure_source_manager.GetBranchRuleRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.BranchRule: + r"""GetBranchRule gets a branch rule. + + .. 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 import securesourcemanager_v1 + + async def sample_get_branch_rule(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetBranchRuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_branch_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.GetBranchRuleRequest, dict]]): + The request object. GetBranchRuleRequest is the request + for getting a branch rule. + name (:class:`str`): + Required. Name of the repository to retrieve. The format + is + ``projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.types.BranchRule: + Metadata of a BranchRule. BranchRule + is the protection rule to enforce + pre-defined rules on designated branches + within a repository. + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.GetBranchRuleRequest): + request = secure_source_manager.GetBranchRuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_branch_rule + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_branch_rule( + self, + request: Optional[ + Union[secure_source_manager.UpdateBranchRuleRequest, dict] + ] = None, + *, + branch_rule: Optional[secure_source_manager.BranchRule] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""UpdateBranchRule updates a branch rule. + + .. 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 import securesourcemanager_v1 + + async def sample_update_branch_rule(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.UpdateBranchRuleRequest( + ) + + # Make the request + operation = client.update_branch_rule(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.UpdateBranchRuleRequest, dict]]): + The request object. UpdateBranchRuleRequest is the + request to update a branchRule. + branch_rule (:class:`google.cloud.securesourcemanager_v1.types.BranchRule`): + + This corresponds to the ``branch_rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Field mask is used to specify the fields to be + overwritten in the branchRule resource by the update. + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. The special value "*" + means full replacement. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.BranchRule` Metadata of a BranchRule. BranchRule is the protection rule to enforce + pre-defined rules on designated branches within a + repository. + + """ + # 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. + flattened_params = [branch_rule, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.UpdateBranchRuleRequest): + request = secure_source_manager.UpdateBranchRuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if branch_rule is not None: + request.branch_rule = branch_rule + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_branch_rule + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("branch_rule.name", request.branch_rule.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.BranchRule, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_branch_rule( + self, + request: Optional[ + Union[secure_source_manager.DeleteBranchRuleRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""DeleteBranchRule deletes a branch rule. + + .. 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 import securesourcemanager_v1 + + async def sample_delete_branch_rule(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeleteBranchRuleRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_branch_rule(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.DeleteBranchRuleRequest, dict]]): + The request object. DeleteBranchRuleRequest is the + request to delete a branch rule. + name (:class:`str`): + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.DeleteBranchRuleRequest): + request = secure_source_manager.DeleteBranchRuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.delete_branch_rule + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_pull_request( + self, + request: Optional[ + Union[secure_source_manager.CreatePullRequestRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + pull_request: Optional[secure_source_manager.PullRequest] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a pull request. + + .. 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 import securesourcemanager_v1 + + async def sample_create_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + pull_request = securesourcemanager_v1.PullRequest() + pull_request.title = "title_value" + pull_request.base.ref = "ref_value" + + request = securesourcemanager_v1.CreatePullRequestRequest( + parent="parent_value", + pull_request=pull_request, + ) + + # Make the request + operation = client.create_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.CreatePullRequestRequest, dict]]): + The request object. CreatePullRequestRequest is the + request to create a pull request. + parent (:class:`str`): + Required. The repository that the pull request is + created from. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + pull_request (:class:`google.cloud.securesourcemanager_v1.types.PullRequest`): + Required. The pull request to create. + This corresponds to the ``pull_request`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.PullRequest` Metadata of a PullRequest. PullRequest is the request + from a user to merge a branch (head) into another + branch (base). + + """ + # 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. + flattened_params = [parent, pull_request] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.CreatePullRequestRequest): + request = secure_source_manager.CreatePullRequestRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if pull_request is not None: + request.pull_request = pull_request + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.create_pull_request + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.PullRequest, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_pull_request( + self, + request: Optional[ + Union[secure_source_manager.GetPullRequestRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.PullRequest: + r"""Gets a pull request. + + .. 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 import securesourcemanager_v1 + + async def sample_get_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetPullRequestRequest( + name="name_value", + ) + + # Make the request + response = await client.get_pull_request(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.GetPullRequestRequest, dict]]): + The request object. GetPullRequestRequest is the request + to get a pull request. + name (:class:`str`): + Required. Name of the pull request to retrieve. The + format is + ``projects/{project}/locations/{location}/repositories/{repository}/pullRequests/{pull_request}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.types.PullRequest: + Metadata of a PullRequest. + PullRequest is the request from a user + to merge a branch (head) into another + branch (base). + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.GetPullRequestRequest): + request = secure_source_manager.GetPullRequestRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_pull_request + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_pull_requests( + self, + request: Optional[ + Union[secure_source_manager.ListPullRequestsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListPullRequestsAsyncPager: + r"""Lists pull requests in a 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 import securesourcemanager_v1 + + async def sample_list_pull_requests(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListPullRequestsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pull_requests(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.ListPullRequestsRequest, dict]]): + The request object. ListPullRequestsRequest is the + request to list pull requests. + parent (:class:`str`): + Required. The repository in which to list pull requests. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListPullRequestsAsyncPager: + ListPullRequestsResponse is the + response to list pull requests. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.ListPullRequestsRequest): + request = secure_source_manager.ListPullRequestsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_pull_requests + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListPullRequestsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_pull_request( + self, + request: Optional[ + Union[secure_source_manager.UpdatePullRequestRequest, dict] + ] = None, + *, + pull_request: Optional[secure_source_manager.PullRequest] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates a pull request. + + .. 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 import securesourcemanager_v1 + + async def sample_update_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + pull_request = securesourcemanager_v1.PullRequest() + pull_request.title = "title_value" + pull_request.base.ref = "ref_value" + + request = securesourcemanager_v1.UpdatePullRequestRequest( + pull_request=pull_request, + ) + + # Make the request + operation = client.update_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.UpdatePullRequestRequest, dict]]): + The request object. UpdatePullRequestRequest is the + request to update a pull request. + pull_request (:class:`google.cloud.securesourcemanager_v1.types.PullRequest`): + Required. The pull request to update. + This corresponds to the ``pull_request`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Optional. Field mask is used to specify the fields to be + overwritten in the pull request resource by the update. + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. The special value "*" + means full replacement. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.PullRequest` Metadata of a PullRequest. PullRequest is the request + from a user to merge a branch (head) into another + branch (base). + + """ + # 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. + flattened_params = [pull_request, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.UpdatePullRequestRequest): + request = secure_source_manager.UpdatePullRequestRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if pull_request is not None: + request.pull_request = pull_request + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_pull_request + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("pull_request.name", request.pull_request.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.PullRequest, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def merge_pull_request( + self, + request: Optional[ + Union[secure_source_manager.MergePullRequestRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Merges a pull request. + + .. 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 import securesourcemanager_v1 + + async def sample_merge_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.MergePullRequestRequest( + name="name_value", + ) + + # Make the request + operation = client.merge_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.MergePullRequestRequest, dict]]): + The request object. MergePullRequestRequest is the + request to merge a pull request. + name (:class:`str`): + Required. The pull request to merge. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.PullRequest` Metadata of a PullRequest. PullRequest is the request + from a user to merge a branch (head) into another + branch (base). + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.MergePullRequestRequest): + request = secure_source_manager.MergePullRequestRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.merge_pull_request + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.PullRequest, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def open_pull_request( + self, + request: Optional[ + Union[secure_source_manager.OpenPullRequestRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Opens a pull request. + + .. 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 import securesourcemanager_v1 + + async def sample_open_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.OpenPullRequestRequest( + name="name_value", + ) + + # Make the request + operation = client.open_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.OpenPullRequestRequest, dict]]): + The request object. OpenPullRequestRequest is the request + to open a pull request. + name (:class:`str`): + Required. The pull request to open. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.PullRequest` Metadata of a PullRequest. PullRequest is the request + from a user to merge a branch (head) into another + branch (base). + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.OpenPullRequestRequest): + request = secure_source_manager.OpenPullRequestRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.open_pull_request + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.PullRequest, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def close_pull_request( + self, + request: Optional[ + Union[secure_source_manager.ClosePullRequestRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Closes a pull request without merging. + + .. 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 import securesourcemanager_v1 + + async def sample_close_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ClosePullRequestRequest( + name="name_value", + ) + + # Make the request + operation = client.close_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.ClosePullRequestRequest, dict]]): + The request object. ClosePullRequestRequest is the + request to close a pull request. + name (:class:`str`): + Required. The pull request to close. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.PullRequest` Metadata of a PullRequest. PullRequest is the request + from a user to merge a branch (head) into another + branch (base). + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.ClosePullRequestRequest): + request = secure_source_manager.ClosePullRequestRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.close_pull_request + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.PullRequest, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_pull_request_file_diffs( + self, + request: Optional[ + Union[secure_source_manager.ListPullRequestFileDiffsRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListPullRequestFileDiffsAsyncPager: + r"""Lists a pull request's file diffs. + + .. 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 import securesourcemanager_v1 + + async def sample_list_pull_request_file_diffs(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListPullRequestFileDiffsRequest( + name="name_value", + ) + + # Make the request + page_result = client.list_pull_request_file_diffs(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.ListPullRequestFileDiffsRequest, dict]]): + The request object. ListPullRequestFileDiffsRequest is + the request to list pull request file + diffs. + name (:class:`str`): + Required. The pull request to list file diffs for. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListPullRequestFileDiffsAsyncPager: + ListPullRequestFileDiffsResponse is + the response containing file diffs + returned from ListPullRequestFileDiffs. + + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.ListPullRequestFileDiffsRequest + ): + request = secure_source_manager.ListPullRequestFileDiffsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_pull_request_file_diffs + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListPullRequestFileDiffsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def fetch_tree( + self, + request: Optional[Union[secure_source_manager.FetchTreeRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.FetchTreeAsyncPager: + r"""Fetches a tree from a 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 import securesourcemanager_v1 + + async def sample_fetch_tree(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.FetchTreeRequest( + repository="repository_value", + ) + + # Make the request + page_result = client.fetch_tree(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.FetchTreeRequest, dict]]): + The request object. Request message for fetching a tree + structure from a repository. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.FetchTreeAsyncPager: + Response message containing a list of + TreeEntry objects. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.FetchTreeRequest): + request = secure_source_manager.FetchTreeRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.fetch_tree + ] + + # 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),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.FetchTreeAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def fetch_blob( + self, + request: Optional[Union[secure_source_manager.FetchBlobRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.FetchBlobResponse: + r"""Fetches a blob from a 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 import securesourcemanager_v1 + + async def sample_fetch_blob(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.FetchBlobRequest( + repository="repository_value", + sha="sha_value", + ) + + # Make the request + response = await client.fetch_blob(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.FetchBlobRequest, dict]]): + The request object. Request message for fetching a blob + (file content) from a repository. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.types.FetchBlobResponse: + Response message containing the + content of a blob. + + """ + # Create or coerce a protobuf request object. + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.FetchBlobRequest): + request = secure_source_manager.FetchBlobRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.fetch_blob + ] + + # 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),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_issue( + self, + request: Optional[Union[secure_source_manager.CreateIssueRequest, dict]] = None, + *, + parent: Optional[str] = None, + issue: Optional[secure_source_manager.Issue] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates an issue. + + .. 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 import securesourcemanager_v1 + + async def sample_create_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + issue = securesourcemanager_v1.Issue() + issue.title = "title_value" + + request = securesourcemanager_v1.CreateIssueRequest( + parent="parent_value", + issue=issue, + ) + + # Make the request + operation = client.create_issue(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.CreateIssueRequest, dict]]): + The request object. The request to create an issue. + parent (:class:`str`): + Required. The repository in which to create the issue. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + issue (:class:`google.cloud.securesourcemanager_v1.types.Issue`): + Required. The issue to create. + This corresponds to the ``issue`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Issue` + Metadata of an Issue. + + """ + # 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. + flattened_params = [parent, issue] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.CreateIssueRequest): + request = secure_source_manager.CreateIssueRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if issue is not None: + request.issue = issue + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.create_issue + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.Issue, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_issue( + self, + request: Optional[Union[secure_source_manager.GetIssueRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.Issue: + r"""Gets an issue. + + .. 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 import securesourcemanager_v1 + + async def sample_get_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetIssueRequest( + name="name_value", + ) + + # Make the request + response = await client.get_issue(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.GetIssueRequest, dict]]): + The request object. The request to get an issue. + name (:class:`str`): + Required. Name of the issue to retrieve. The format is + ``projects/{project}/locations/{location}/repositories/{repository}/issues/{issue_id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.types.Issue: + Metadata of an Issue. + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.GetIssueRequest): + request = secure_source_manager.GetIssueRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_issue + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_issues( + self, + request: Optional[Union[secure_source_manager.ListIssuesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListIssuesAsyncPager: + r"""Lists issues in a 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 import securesourcemanager_v1 + + async def sample_list_issues(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListIssuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_issues(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.ListIssuesRequest, dict]]): + The request object. The request to list issues. + parent (:class:`str`): + Required. The repository in which to list issues. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListIssuesAsyncPager: + The response to list issues. + + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.ListIssuesRequest): + request = secure_source_manager.ListIssuesRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_issues + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListIssuesAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_issue( + self, + request: Optional[Union[secure_source_manager.UpdateIssueRequest, dict]] = None, + *, + issue: Optional[secure_source_manager.Issue] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates a issue. + + .. 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 import securesourcemanager_v1 + + async def sample_update_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + issue = securesourcemanager_v1.Issue() + issue.title = "title_value" + + request = securesourcemanager_v1.UpdateIssueRequest( + issue=issue, + ) + + # Make the request + operation = client.update_issue(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.UpdateIssueRequest, dict]]): + The request object. The request to update an issue. + issue (:class:`google.cloud.securesourcemanager_v1.types.Issue`): + Required. The issue to update. + This corresponds to the ``issue`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Optional. Field mask is used to specify the fields to be + overwritten in the issue resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. The special value "*" + means full replacement. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Issue` + Metadata of an Issue. + + """ + # 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. + flattened_params = [issue, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.UpdateIssueRequest): + request = secure_source_manager.UpdateIssueRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue is not None: + request.issue = issue + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_issue + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("issue.name", request.issue.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.Issue, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_issue( + self, + request: Optional[Union[secure_source_manager.DeleteIssueRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes an issue. + + .. 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 import securesourcemanager_v1 + + async def sample_delete_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeleteIssueRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_issue(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.DeleteIssueRequest, dict]]): + The request object. The request to delete an issue. + name (:class:`str`): + Required. Name of the issue to delete. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.DeleteIssueRequest): + request = secure_source_manager.DeleteIssueRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.delete_issue + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def open_issue( + self, + request: Optional[Union[secure_source_manager.OpenIssueRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Opens an issue. + + .. 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 import securesourcemanager_v1 + + async def sample_open_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.OpenIssueRequest( + name="name_value", + ) + + # Make the request + operation = client.open_issue(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.OpenIssueRequest, dict]]): + The request object. The request to open an issue. + name (:class:`str`): + Required. Name of the issue to open. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Issue` + Metadata of an Issue. + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.OpenIssueRequest): + request = secure_source_manager.OpenIssueRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.open_issue + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.Issue, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def close_issue( + self, + request: Optional[Union[secure_source_manager.CloseIssueRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Closes an issue. + + .. 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 import securesourcemanager_v1 + + async def sample_close_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.CloseIssueRequest( + name="name_value", + ) + + # Make the request + operation = client.close_issue(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.CloseIssueRequest, dict]]): + The request object. The request to close an issue. + name (:class:`str`): + Required. Name of the issue to close. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Issue` + Metadata of an Issue. + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.CloseIssueRequest): + request = secure_source_manager.CloseIssueRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.close_issue + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.Issue, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def get_pull_request_comment( + self, + request: Optional[ + Union[secure_source_manager.GetPullRequestCommentRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.PullRequestComment: + r"""Gets a pull request comment. + + .. 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 import securesourcemanager_v1 + + async def sample_get_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetPullRequestCommentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_pull_request_comment(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.GetPullRequestCommentRequest, dict]]): + The request object. The request to get a pull request + comment. + name (:class:`str`): + Required. Name of the pull request comment to retrieve. + The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}/pullRequestComments/{comment_id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.types.PullRequestComment: + PullRequestComment represents a + comment on a pull request. + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.GetPullRequestCommentRequest): + request = secure_source_manager.GetPullRequestCommentRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.get_pull_request_comment + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_pull_request_comments( + self, + request: Optional[ + Union[secure_source_manager.ListPullRequestCommentsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListPullRequestCommentsAsyncPager: + r"""Lists pull request comments. + + .. 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 import securesourcemanager_v1 + + async def sample_list_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListPullRequestCommentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pull_request_comments(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.ListPullRequestCommentsRequest, dict]]): + The request object. The request to list pull request + comments. + parent (:class:`str`): + Required. The pull request in which to list pull request + comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListPullRequestCommentsAsyncPager: + The response to list pull request + comments. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.ListPullRequestCommentsRequest + ): + request = secure_source_manager.ListPullRequestCommentsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.list_pull_request_comments + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListPullRequestCommentsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_pull_request_comment( + self, + request: Optional[ + Union[secure_source_manager.CreatePullRequestCommentRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + pull_request_comment: Optional[secure_source_manager.PullRequestComment] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a pull request comment. + + .. 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 import securesourcemanager_v1 + + async def sample_create_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + pull_request_comment = securesourcemanager_v1.PullRequestComment() + pull_request_comment.review.action_type = "APPROVED" + + request = securesourcemanager_v1.CreatePullRequestCommentRequest( + parent="parent_value", + pull_request_comment=pull_request_comment, + ) + + # Make the request + operation = client.create_pull_request_comment(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.CreatePullRequestCommentRequest, dict]]): + The request object. The request to create a pull request + comment. + parent (:class:`str`): + Required. The pull request in which to create the pull + request comment. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + pull_request_comment (:class:`google.cloud.securesourcemanager_v1.types.PullRequestComment`): + Required. The pull request comment to + create. + + This corresponds to the ``pull_request_comment`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.PullRequestComment` + PullRequestComment represents a comment on a pull + request. + + """ + # 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. + flattened_params = [parent, pull_request_comment] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.CreatePullRequestCommentRequest + ): + request = secure_source_manager.CreatePullRequestCommentRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if pull_request_comment is not None: + request.pull_request_comment = pull_request_comment + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.create_pull_request_comment + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.PullRequestComment, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_pull_request_comment( + self, + request: Optional[ + Union[secure_source_manager.UpdatePullRequestCommentRequest, dict] + ] = None, + *, + pull_request_comment: Optional[secure_source_manager.PullRequestComment] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates a pull request comment. + + .. 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 import securesourcemanager_v1 + + async def sample_update_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + pull_request_comment = securesourcemanager_v1.PullRequestComment() + pull_request_comment.review.action_type = "APPROVED" + + request = securesourcemanager_v1.UpdatePullRequestCommentRequest( + pull_request_comment=pull_request_comment, + ) + + # Make the request + operation = client.update_pull_request_comment(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.UpdatePullRequestCommentRequest, dict]]): + The request object. The request to update a pull request + comment. + pull_request_comment (:class:`google.cloud.securesourcemanager_v1.types.PullRequestComment`): + Required. The pull request comment to + update. + + This corresponds to the ``pull_request_comment`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Optional. Field mask is used to specify the fields to be + overwritten in the pull request comment resource by the + update. Updatable fields are ``body``. + + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.PullRequestComment` + PullRequestComment represents a comment on a pull + request. + + """ + # 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. + flattened_params = [pull_request_comment, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.UpdatePullRequestCommentRequest + ): + request = secure_source_manager.UpdatePullRequestCommentRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if pull_request_comment is not None: + request.pull_request_comment = pull_request_comment + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.update_pull_request_comment + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("pull_request_comment.name", request.pull_request_comment.name),) + ), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.PullRequestComment, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_pull_request_comment( + self, + request: Optional[ + Union[secure_source_manager.DeletePullRequestCommentRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes a pull request comment. + + .. 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 import securesourcemanager_v1 + + async def sample_delete_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeletePullRequestCommentRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_pull_request_comment(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.DeletePullRequestCommentRequest, dict]]): + The request object. The request to delete a pull request + comment. A Review PullRequestComment + cannot be deleted. + name (:class:`str`): + Required. Name of the pull request comment to delete. + The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}/pullRequestComments/{comment_id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: - **JSON example:** + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + } - **YAML example:** + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.DeletePullRequestCommentRequest + ): + request = secure_source_manager.DeletePullRequestCommentRequest(request) - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.delete_pull_request_comment + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + empty_pb2.Empty, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def batch_create_pull_request_comments( + self, + request: Optional[ + Union[secure_source_manager.BatchCreatePullRequestCommentsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + requests: Optional[ + MutableSequence[secure_source_manager.CreatePullRequestCommentRequest] + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Batch creates pull request comments. + + .. 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 import securesourcemanager_v1 + + async def sample_batch_create_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + requests = securesourcemanager_v1.CreatePullRequestCommentRequest() + requests.parent = "parent_value" + requests.pull_request_comment.review.action_type = "APPROVED" + + request = securesourcemanager_v1.BatchCreatePullRequestCommentsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + operation = client.batch_create_pull_request_comments(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.BatchCreatePullRequestCommentsRequest, dict]]): + The request object. The request to batch create pull + request comments. + parent (:class:`str`): + Required. The pull request in which to create the pull + request comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + requests (:class:`MutableSequence[google.cloud.securesourcemanager_v1.types.CreatePullRequestCommentRequest]`): + Required. The request message + specifying the resources to create. + There should be exactly one + CreatePullRequestCommentRequest with + CommentDetail being REVIEW in the list, + and no more than 100 + CreatePullRequestCommentRequests with + CommentDetail being CODE in the list + + This corresponds to the ``requests`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.BatchCreatePullRequestCommentsResponse` + The response to batch create pull request comments. """ # 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. - flattened_params = [resource] + flattened_params = [parent, requests] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -1638,23 +6170,177 @@ async def sample_set_iam_policy_repo(): "the individual field arguments should be set." ) - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = iam_policy_pb2.SetIamPolicyRequest(**request) - elif not request: - request = iam_policy_pb2.SetIamPolicyRequest(resource=resource) + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.BatchCreatePullRequestCommentsRequest + ): + request = secure_source_manager.BatchCreatePullRequestCommentsRequest( + request + ) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if requests: + request.requests.extend(requests) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[ + self._client._transport.batch_create_pull_request_comments + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.BatchCreatePullRequestCommentsResponse, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + async def resolve_pull_request_comments( + self, + request: Optional[ + Union[secure_source_manager.ResolvePullRequestCommentsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + names: Optional[MutableSequence[str]] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Resolves pull request comments. + + .. 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 import securesourcemanager_v1 + + async def sample_resolve_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ResolvePullRequestCommentsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], + ) + + # Make the request + operation = client.resolve_pull_request_comments(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securesourcemanager_v1.types.ResolvePullRequestCommentsRequest, dict]]): + The request object. The request to resolve multiple pull + request comments. + parent (:class:`str`): + Required. The pull request in which to resolve the pull + request comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + names (:class:`MutableSequence[str]`): + Required. The names of the pull request comments to + resolve. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}/pullRequestComments/{comment_id}`` + Only comments from the same threads are allowed in the + same request. + + This corresponds to the ``names`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.ResolvePullRequestCommentsResponse` + The response to resolve multiple pull request comments. + + """ + # 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. + flattened_params = [parent, names] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.ResolvePullRequestCommentsRequest + ): + request = secure_source_manager.ResolvePullRequestCommentsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if names: + request.names.extend(names) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.set_iam_policy_repo + self._client._transport.resolve_pull_request_comments ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -1668,20 +6354,30 @@ async def sample_set_iam_policy_repo(): metadata=metadata, ) + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.ResolvePullRequestCommentsResponse, + metadata_type=secure_source_manager.OperationMetadata, + ) + # Done; return the response. return response - async def test_iam_permissions_repo( + async def unresolve_pull_request_comments( self, - request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, + request: Optional[ + Union[secure_source_manager.UnresolvePullRequestCommentsRequest, dict] + ] = None, *, - resource: Optional[str] = None, + parent: Optional[str] = None, + names: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Test IAM permissions on a repository. - IAM permission checks are not required on this method. + ) -> operation_async.AsyncOperation: + r"""Unresolves pull request comment. .. code-block:: python @@ -1693,34 +6389,47 @@ async def test_iam_permissions_repo( # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - from google.iam.v1 import iam_policy_pb2 # type: ignore - async def sample_test_iam_permissions_repo(): + async def sample_unresolve_pull_request_comments(): # Create a client client = securesourcemanager_v1.SecureSourceManagerAsyncClient() # Initialize request argument(s) - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", - permissions=['permissions_value1', 'permissions_value2'], + request = securesourcemanager_v1.UnresolvePullRequestCommentsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], ) # Make the request - response = await client.test_iam_permissions_repo(request=request) + operation = client.unresolve_pull_request_comments(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() # Handle the response print(response) Args: - request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]): - The request object. Request message for ``TestIamPermissions`` method. - resource (:class:`str`): - REQUIRED: The resource for which the - policy detail is being requested. See - the operation documentation for the - appropriate value for this field. + request (Optional[Union[google.cloud.securesourcemanager_v1.types.UnresolvePullRequestCommentsRequest, dict]]): + The request object. The request to unresolve multiple + pull request comments. + parent (:class:`str`): + Required. The pull request in which to resolve the pull + request comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` - This corresponds to the ``resource`` field + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + names (:class:`MutableSequence[str]`): + Required. The names of the pull request comments to + unresolve. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}/pullRequestComments/{comment_id}`` + Only comments from the same threads are allowed in the + same request. + + This corresponds to the ``names`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1732,13 +6441,19 @@ async def sample_test_iam_permissions_repo(): be of type `bytes`. Returns: - google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: - Response message for TestIamPermissions method. + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.UnresolvePullRequestCommentsResponse` + The response to unresolve multiple pull request + comments. + """ # 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. - flattened_params = [resource] + flattened_params = [parent, names] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -1748,23 +6463,30 @@ async def sample_test_iam_permissions_repo(): "the individual field arguments should be set." ) - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = iam_policy_pb2.TestIamPermissionsRequest(**request) - elif not request: - request = iam_policy_pb2.TestIamPermissionsRequest(resource=resource) + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.UnresolvePullRequestCommentsRequest + ): + request = secure_source_manager.UnresolvePullRequestCommentsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if names: + request.names.extend(names) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.test_iam_permissions_repo + self._client._transport.unresolve_pull_request_comments ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -1778,24 +6500,30 @@ async def sample_test_iam_permissions_repo(): metadata=metadata, ) + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + secure_source_manager.UnresolvePullRequestCommentsResponse, + metadata_type=secure_source_manager.OperationMetadata, + ) + # Done; return the response. return response - async def create_branch_rule( + async def create_issue_comment( self, request: Optional[ - Union[secure_source_manager.CreateBranchRuleRequest, dict] + Union[secure_source_manager.CreateIssueCommentRequest, dict] ] = None, *, parent: Optional[str] = None, - branch_rule: Optional[secure_source_manager.BranchRule] = None, - branch_rule_id: Optional[str] = None, + issue_comment: Optional[secure_source_manager.IssueComment] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: - r"""CreateBranchRule creates a branch rule in a given - repository. + r"""Creates an issue comment. .. code-block:: python @@ -1808,18 +6536,21 @@ async def create_branch_rule( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - async def sample_create_branch_rule(): + async def sample_create_issue_comment(): # Create a client client = securesourcemanager_v1.SecureSourceManagerAsyncClient() # Initialize request argument(s) - request = securesourcemanager_v1.CreateBranchRuleRequest( + issue_comment = securesourcemanager_v1.IssueComment() + issue_comment.body = "body_value" + + request = securesourcemanager_v1.CreateIssueCommentRequest( parent="parent_value", - branch_rule_id="branch_rule_id_value", + issue_comment=issue_comment, ) # Make the request - operation = client.create_branch_rule(request=request) + operation = client.create_issue_comment(request=request) print("Waiting for operation to complete...") @@ -1829,22 +6560,22 @@ async def sample_create_branch_rule(): print(response) Args: - request (Optional[Union[google.cloud.securesourcemanager_v1.types.CreateBranchRuleRequest, dict]]): - The request object. CreateBranchRuleRequest is the - request to create a branch rule. + request (Optional[Union[google.cloud.securesourcemanager_v1.types.CreateIssueCommentRequest, dict]]): + The request object. The request to create an issue + comment. parent (:class:`str`): + Required. The issue in which to create the issue + comment. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}`` This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - branch_rule (:class:`google.cloud.securesourcemanager_v1.types.BranchRule`): - - This corresponds to the ``branch_rule`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - branch_rule_id (:class:`str`): + issue_comment (:class:`google.cloud.securesourcemanager_v1.types.IssueComment`): + Required. The issue comment to + create. - This corresponds to the ``branch_rule_id`` field + This corresponds to the ``issue_comment`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1859,15 +6590,15 @@ async def sample_create_branch_rule(): google.api_core.operation_async.AsyncOperation: An object representing a long-running operation. - The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.BranchRule` Metadata of a BranchRule. BranchRule is the protection rule to enforce - pre-defined rules on desginated branches within a - repository. + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.IssueComment` + IssueComment represents a comment on an issue. """ # 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. - flattened_params = [parent, branch_rule, branch_rule_id] + flattened_params = [parent, issue_comment] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -1879,22 +6610,20 @@ async def sample_create_branch_rule(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, secure_source_manager.CreateBranchRuleRequest): - request = secure_source_manager.CreateBranchRuleRequest(request) + if not isinstance(request, secure_source_manager.CreateIssueCommentRequest): + request = secure_source_manager.CreateIssueCommentRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent - if branch_rule is not None: - request.branch_rule = branch_rule - if branch_rule_id is not None: - request.branch_rule_id = branch_rule_id + if issue_comment is not None: + request.issue_comment = issue_comment # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.create_branch_rule + self._client._transport.create_issue_comment ] # Certain fields should be provided within the metadata header; @@ -1918,26 +6647,25 @@ async def sample_create_branch_rule(): response = operation_async.from_gapic( response, self._client._transport.operations_client, - secure_source_manager.BranchRule, + secure_source_manager.IssueComment, metadata_type=secure_source_manager.OperationMetadata, ) # Done; return the response. return response - async def list_branch_rules( + async def get_issue_comment( self, request: Optional[ - Union[secure_source_manager.ListBranchRulesRequest, dict] + Union[secure_source_manager.GetIssueCommentRequest, dict] ] = None, *, - parent: Optional[str] = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListBranchRulesAsyncPager: - r"""ListBranchRules lists branch rules in a given - repository. + ) -> secure_source_manager.IssueComment: + r"""Gets an issue comment. .. code-block:: python @@ -1950,29 +6678,30 @@ async def list_branch_rules( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - async def sample_list_branch_rules(): + async def sample_get_issue_comment(): # Create a client client = securesourcemanager_v1.SecureSourceManagerAsyncClient() # Initialize request argument(s) - request = securesourcemanager_v1.ListBranchRulesRequest( - parent="parent_value", + request = securesourcemanager_v1.GetIssueCommentRequest( + name="name_value", ) # Make the request - page_result = client.list_branch_rules(request=request) + response = await client.get_issue_comment(request=request) # Handle the response - async for response in page_result: - print(response) + print(response) Args: - request (Optional[Union[google.cloud.securesourcemanager_v1.types.ListBranchRulesRequest, dict]]): - The request object. ListBranchRulesRequest is the request - to list branch rules. - parent (:class:`str`): + request (Optional[Union[google.cloud.securesourcemanager_v1.types.GetIssueCommentRequest, dict]]): + The request object. The request to get an issue comment. + name (:class:`str`): + Required. Name of the issue comment to retrieve. The + format is + ``projects/{project}/locations/{location}/repositories/{repository}/issues/{issue_id}/issueComments/{comment_id}``. - This corresponds to the ``parent`` field + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1984,18 +6713,15 @@ async def sample_list_branch_rules(): be of type `bytes`. Returns: - google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListBranchRulesAsyncPager: - ListBranchRulesResponse is the - response to listing branchRules. - Iterating over this object will yield - results and resolve additional pages - automatically. + google.cloud.securesourcemanager_v1.types.IssueComment: + IssueComment represents a comment on + an issue. """ # 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. - flattened_params = [parent] + flattened_params = [name] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -2007,24 +6733,24 @@ async def sample_list_branch_rules(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, secure_source_manager.ListBranchRulesRequest): - request = secure_source_manager.ListBranchRulesRequest(request) + if not isinstance(request, secure_source_manager.GetIssueCommentRequest): + request = secure_source_manager.GetIssueCommentRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: - request.parent = parent + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.list_branch_rules + self._client._transport.get_issue_comment ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Validate the universe domain. @@ -2038,32 +6764,21 @@ async def sample_list_branch_rules(): metadata=metadata, ) - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.ListBranchRulesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - # Done; return the response. return response - async def get_branch_rule( + async def list_issue_comments( self, request: Optional[ - Union[secure_source_manager.GetBranchRuleRequest, dict] + Union[secure_source_manager.ListIssueCommentsRequest, dict] ] = None, *, - name: Optional[str] = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> secure_source_manager.BranchRule: - r"""GetBranchRule gets a branch rule. + ) -> pagers.ListIssueCommentsAsyncPager: + r"""Lists comments in an issue. .. code-block:: python @@ -2076,31 +6791,31 @@ async def get_branch_rule( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - async def sample_get_branch_rule(): + async def sample_list_issue_comments(): # Create a client client = securesourcemanager_v1.SecureSourceManagerAsyncClient() # Initialize request argument(s) - request = securesourcemanager_v1.GetBranchRuleRequest( - name="name_value", + request = securesourcemanager_v1.ListIssueCommentsRequest( + parent="parent_value", ) # Make the request - response = await client.get_branch_rule(request=request) + page_result = client.list_issue_comments(request=request) # Handle the response - print(response) + async for response in page_result: + print(response) Args: - request (Optional[Union[google.cloud.securesourcemanager_v1.types.GetBranchRuleRequest, dict]]): - The request object. GetBranchRuleRequest is the request - for getting a branch rule. - name (:class:`str`): - Required. Name of the repository to retrieve. The format - is - ``projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}``. + request (Optional[Union[google.cloud.securesourcemanager_v1.types.ListIssueCommentsRequest, dict]]): + The request object. The request to list issue comments. + parent (:class:`str`): + Required. The issue in which to list the comments. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}`` - This corresponds to the ``name`` field + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -2112,17 +6827,18 @@ async def sample_get_branch_rule(): be of type `bytes`. Returns: - google.cloud.securesourcemanager_v1.types.BranchRule: - Metadata of a BranchRule. BranchRule - is the protection rule to enforce - pre-defined rules on desginated branches - within a repository. + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListIssueCommentsAsyncPager: + The response to list issue comments. + + Iterating over this object will yield + results and resolve additional pages + automatically. """ # 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. - flattened_params = [name] + flattened_params = [parent] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -2134,24 +6850,24 @@ async def sample_get_branch_rule(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, secure_source_manager.GetBranchRuleRequest): - request = secure_source_manager.GetBranchRuleRequest(request) + if not isinstance(request, secure_source_manager.ListIssueCommentsRequest): + request = secure_source_manager.ListIssueCommentsRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if parent is not None: + request.parent = parent # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.get_branch_rule + self._client._transport.list_issue_comments ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -2165,22 +6881,33 @@ async def sample_get_branch_rule(): metadata=metadata, ) + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListIssueCommentsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + # Done; return the response. return response - async def update_branch_rule( + async def update_issue_comment( self, request: Optional[ - Union[secure_source_manager.UpdateBranchRuleRequest, dict] + Union[secure_source_manager.UpdateIssueCommentRequest, dict] ] = None, *, - branch_rule: Optional[secure_source_manager.BranchRule] = None, + issue_comment: Optional[secure_source_manager.IssueComment] = None, update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: - r"""UpdateBranchRule updates a branch rule. + r"""Updates an issue comment. .. code-block:: python @@ -2193,16 +6920,20 @@ async def update_branch_rule( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - async def sample_update_branch_rule(): + async def sample_update_issue_comment(): # Create a client client = securesourcemanager_v1.SecureSourceManagerAsyncClient() # Initialize request argument(s) - request = securesourcemanager_v1.UpdateBranchRuleRequest( + issue_comment = securesourcemanager_v1.IssueComment() + issue_comment.body = "body_value" + + request = securesourcemanager_v1.UpdateIssueCommentRequest( + issue_comment=issue_comment, ) # Make the request - operation = client.update_branch_rule(request=request) + operation = client.update_issue_comment(request=request) print("Waiting for operation to complete...") @@ -2212,17 +6943,19 @@ async def sample_update_branch_rule(): print(response) Args: - request (Optional[Union[google.cloud.securesourcemanager_v1.types.UpdateBranchRuleRequest, dict]]): - The request object. UpdateBranchRuleRequest is the - request to update a branchRule. - branch_rule (:class:`google.cloud.securesourcemanager_v1.types.BranchRule`): - - This corresponds to the ``branch_rule`` field + request (Optional[Union[google.cloud.securesourcemanager_v1.types.UpdateIssueCommentRequest, dict]]): + The request object. The request to update an issue + comment. + issue_comment (:class:`google.cloud.securesourcemanager_v1.types.IssueComment`): + Required. The issue comment to + update. + + This corresponds to the ``issue_comment`` field on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Field mask is used to specify the fields to be - overwritten in the branchRule resource by the update. + Optional. Field mask is used to specify the fields to be + overwritten in the issue comment resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. The special value "*" @@ -2243,15 +6976,15 @@ async def sample_update_branch_rule(): google.api_core.operation_async.AsyncOperation: An object representing a long-running operation. - The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.BranchRule` Metadata of a BranchRule. BranchRule is the protection rule to enforce - pre-defined rules on desginated branches within a - repository. + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.IssueComment` + IssueComment represents a comment on an issue. """ # 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. - flattened_params = [branch_rule, update_mask] + flattened_params = [issue_comment, update_mask] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -2263,27 +6996,27 @@ async def sample_update_branch_rule(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, secure_source_manager.UpdateBranchRuleRequest): - request = secure_source_manager.UpdateBranchRuleRequest(request) + if not isinstance(request, secure_source_manager.UpdateIssueCommentRequest): + request = secure_source_manager.UpdateIssueCommentRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if branch_rule is not None: - request.branch_rule = branch_rule + if issue_comment is not None: + request.issue_comment = issue_comment if update_mask is not None: request.update_mask = update_mask # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.update_branch_rule + self._client._transport.update_issue_comment ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( - (("branch_rule.name", request.branch_rule.name),) + (("issue_comment.name", request.issue_comment.name),) ), ) @@ -2302,17 +7035,17 @@ async def sample_update_branch_rule(): response = operation_async.from_gapic( response, self._client._transport.operations_client, - secure_source_manager.BranchRule, + secure_source_manager.IssueComment, metadata_type=secure_source_manager.OperationMetadata, ) # Done; return the response. return response - async def delete_branch_rule( + async def delete_issue_comment( self, request: Optional[ - Union[secure_source_manager.DeleteBranchRuleRequest, dict] + Union[secure_source_manager.DeleteIssueCommentRequest, dict] ] = None, *, name: Optional[str] = None, @@ -2320,7 +7053,7 @@ async def delete_branch_rule( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: - r"""DeleteBranchRule deletes a branch rule. + r"""Deletes an issue comment. .. code-block:: python @@ -2333,17 +7066,17 @@ async def delete_branch_rule( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - async def sample_delete_branch_rule(): + async def sample_delete_issue_comment(): # Create a client client = securesourcemanager_v1.SecureSourceManagerAsyncClient() # Initialize request argument(s) - request = securesourcemanager_v1.DeleteBranchRuleRequest( + request = securesourcemanager_v1.DeleteIssueCommentRequest( name="name_value", ) # Make the request - operation = client.delete_branch_rule(request=request) + operation = client.delete_issue_comment(request=request) print("Waiting for operation to complete...") @@ -2353,10 +7086,13 @@ async def sample_delete_branch_rule(): print(response) Args: - request (Optional[Union[google.cloud.securesourcemanager_v1.types.DeleteBranchRuleRequest, dict]]): - The request object. DeleteBranchRuleRequest is the - request to delete a branch rule. + request (Optional[Union[google.cloud.securesourcemanager_v1.types.DeleteIssueCommentRequest, dict]]): + The request object. The request to delete an issue + comment. name (:class:`str`): + Required. Name of the issue comment to delete. The + format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}/issueComments/{comment_id}``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -2400,8 +7136,8 @@ async def sample_delete_branch_rule(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, secure_source_manager.DeleteBranchRuleRequest): - request = secure_source_manager.DeleteBranchRuleRequest(request) + if not isinstance(request, secure_source_manager.DeleteIssueCommentRequest): + request = secure_source_manager.DeleteIssueCommentRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. @@ -2411,7 +7147,7 @@ async def sample_delete_branch_rule(): # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._client._transport._wrapped_methods[ - self._client._transport.delete_branch_rule + self._client._transport.delete_issue_comment ] # Certain fields should be provided within the metadata header; diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/client.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/client.py index 60653f5b4445..75c67eb3a53c 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/client.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/client.py @@ -120,29 +120,8 @@ def get_transport_class( class SecureSourceManagerClient(metaclass=SecureSourceManagerClientMeta): """Secure Source Manager API - Access Secure Source Manager instances, resources, and repositories. - - This API is split across two servers: the Control Plane and the Data - Plane. - - Data Plane endpoints are hosted directly by your Secure Source - Manager instance, so you must connect to your instance's API - hostname to access them. The API hostname looks like the following: - - :: - - https://[instance-id]-[project-number]-api.[location].sourcemanager.dev - - For example, - - :: - - https://my-instance-702770452863-api.us-central1.sourcemanager.dev - - Data Plane endpoints are denoted with **Host: Data Plane**. - - All other endpoints are found in the normal Cloud API location, - namely, ``securcesourcemanager.googleapis.com``. + Access Secure Source Manager instances, resources, and + repositories. """ @staticmethod @@ -301,6 +280,30 @@ def parse_crypto_key_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def hook_path( + project: str, + location: str, + repository: str, + hook: str, + ) -> str: + """Returns a fully-qualified hook string.""" + return "projects/{project}/locations/{location}/repositories/{repository}/hooks/{hook}".format( + project=project, + location=location, + repository=repository, + hook=hook, + ) + + @staticmethod + def parse_hook_path(path: str) -> Dict[str, str]: + """Parses a hook path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/hooks/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def instance_path( project: str, @@ -323,6 +326,106 @@ def parse_instance_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def issue_path( + project: str, + location: str, + repository: str, + issue: str, + ) -> str: + """Returns a fully-qualified issue string.""" + return "projects/{project}/locations/{location}/repositories/{repository}/issues/{issue}".format( + project=project, + location=location, + repository=repository, + issue=issue, + ) + + @staticmethod + def parse_issue_path(path: str) -> Dict[str, str]: + """Parses a issue path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/issues/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def issue_comment_path( + project: str, + location: str, + repository: str, + issue: str, + comment: str, + ) -> str: + """Returns a fully-qualified issue_comment string.""" + return "projects/{project}/locations/{location}/repositories/{repository}/issues/{issue}/issueComments/{comment}".format( + project=project, + location=location, + repository=repository, + issue=issue, + comment=comment, + ) + + @staticmethod + def parse_issue_comment_path(path: str) -> Dict[str, str]: + """Parses a issue_comment path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/issues/(?P.+?)/issueComments/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def pull_request_path( + project: str, + location: str, + repository: str, + pull_request: str, + ) -> str: + """Returns a fully-qualified pull_request string.""" + return "projects/{project}/locations/{location}/repositories/{repository}/pullRequests/{pull_request}".format( + project=project, + location=location, + repository=repository, + pull_request=pull_request, + ) + + @staticmethod + def parse_pull_request_path(path: str) -> Dict[str, str]: + """Parses a pull_request path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/pullRequests/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def pull_request_comment_path( + project: str, + location: str, + repository: str, + pull_request: str, + comment: str, + ) -> str: + """Returns a fully-qualified pull_request_comment string.""" + return "projects/{project}/locations/{location}/repositories/{repository}/pullRequests/{pull_request}/pullRequestComments/{comment}".format( + project=project, + location=location, + repository=repository, + pull_request=pull_request, + comment=comment, + ) + + @staticmethod + def parse_pull_request_comment_path(path: str) -> Dict[str, str]: + """Parses a pull_request_comment path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/repositories/(?P.+?)/pullRequests/(?P.+?)/pullRequestComments/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def repository_path( project: str, @@ -1382,7 +1485,9 @@ def list_repositories( ) -> pagers.ListRepositoriesPager: r"""Lists Repositories in a given project and location. - **Host: Data Plane** + The instance field is required in the query parameter + for requests using the + securesourcemanager.googleapis.com endpoint. .. code-block:: python @@ -1507,8 +1612,6 @@ def get_repository( ) -> secure_source_manager.Repository: r"""Gets metadata of a repository. - **Host: Data Plane** - .. code-block:: python # This snippet has been automatically generated and should be regarded as a @@ -1620,9 +1723,11 @@ def create_repository( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: - r"""Creates a new repository in a given project and location. - - **Host: Data Plane** + r"""Creates a new repository in a given project and + location. + The Repository.Instance field is required in the request + body for requests using the + securesourcemanager.googleapis.com endpoint. .. code-block:: python @@ -1756,20 +1861,19 @@ def sample_create_repository(): # Done; return the response. return response - def delete_repository( + def update_repository( self, request: Optional[ - Union[secure_source_manager.DeleteRepositoryRequest, dict] + Union[secure_source_manager.UpdateRepositoryRequest, dict] ] = None, *, - name: Optional[str] = None, + repository: Optional[secure_source_manager.Repository] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: - r"""Deletes a Repository. - - **Host: Data Plane** + r"""Updates the metadata of a repository. .. code-block:: python @@ -1782,17 +1886,16 @@ def delete_repository( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - def sample_delete_repository(): + def sample_update_repository(): # Create a client client = securesourcemanager_v1.SecureSourceManagerClient() # Initialize request argument(s) - request = securesourcemanager_v1.DeleteRepositoryRequest( - name="name_value", + request = securesourcemanager_v1.UpdateRepositoryRequest( ) # Make the request - operation = client.delete_repository(request=request) + operation = client.update_repository(request=request) print("Waiting for operation to complete...") @@ -1802,15 +1905,25 @@ def sample_delete_repository(): print(response) Args: - request (Union[google.cloud.securesourcemanager_v1.types.DeleteRepositoryRequest, dict]): - The request object. DeleteRepositoryRequest is the - request to delete a repository. - name (str): - Required. Name of the repository to delete. The format - is - projects/{project_number}/locations/{location_id}/repositories/{repository_id}. + request (Union[google.cloud.securesourcemanager_v1.types.UpdateRepositoryRequest, dict]): + The request object. UpdateRepositoryRequest is the + request to update a repository. + repository (google.cloud.securesourcemanager_v1.types.Repository): + Required. The repository being + updated. - This corresponds to the ``name`` field + This corresponds to the ``repository`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the repository resource by the update. + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + + This corresponds to the ``update_mask`` 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, @@ -1825,22 +1938,15 @@ def sample_delete_repository(): google.api_core.operation.Operation: An object representing a long-running operation. - The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated - empty messages in your APIs. A typical example is to - use it as the request or the response type of an API - method. For instance: - - service Foo { - rpc Bar(google.protobuf.Empty) returns - (google.protobuf.Empty); - - } + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Repository` + Metadata of a Secure Source Manager repository. """ # 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. - flattened_params = [name] + flattened_params = [repository, update_mask] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -1852,21 +1958,25 @@ def sample_delete_repository(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, secure_source_manager.DeleteRepositoryRequest): - request = secure_source_manager.DeleteRepositoryRequest(request) + if not isinstance(request, secure_source_manager.UpdateRepositoryRequest): + request = secure_source_manager.UpdateRepositoryRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if repository is not None: + request.repository = repository + if update_mask is not None: + request.update_mask = update_mask # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_repository] + rpc = self._transport._wrapped_methods[self._transport.update_repository] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + gapic_v1.routing_header.to_grpc_metadata( + (("repository.name", request.repository.name),) + ), ) # Validate the universe domain. @@ -1884,23 +1994,25 @@ def sample_delete_repository(): response = operation.from_gapic( response, self._transport.operations_client, - empty_pb2.Empty, + secure_source_manager.Repository, metadata_type=secure_source_manager.OperationMetadata, ) # Done; return the response. return response - def get_iam_policy_repo( + def delete_repository( self, - request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, + request: Optional[ + Union[secure_source_manager.DeleteRepositoryRequest, dict] + ] = None, *, - resource: Optional[str] = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> policy_pb2.Policy: - r"""Get IAM policy for a repository. + ) -> operation.Operation: + r"""Deletes a Repository. .. code-block:: python @@ -1912,33 +2024,36 @@ def get_iam_policy_repo( # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_get_iam_policy_repo(): + def sample_delete_repository(): # Create a client client = securesourcemanager_v1.SecureSourceManagerClient() # Initialize request argument(s) - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", + request = securesourcemanager_v1.DeleteRepositoryRequest( + name="name_value", ) # Make the request - response = client.get_iam_policy_repo(request=request) + operation = client.delete_repository(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() # Handle the response print(response) Args: - request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): - The request object. Request message for ``GetIamPolicy`` method. - resource (str): - REQUIRED: The resource for which the - policy is being requested. See the - operation documentation for the - appropriate value for this field. + request (Union[google.cloud.securesourcemanager_v1.types.DeleteRepositoryRequest, dict]): + The request object. DeleteRepositoryRequest is the + request to delete a repository. + name (str): + Required. Name of the repository to delete. The format + is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}``. - This corresponds to the ``resource`` field + This corresponds to the ``name`` 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, @@ -1950,43 +2065,25 @@ def sample_get_iam_policy_repo(): be of type `bytes`. Returns: - google.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. - - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. - - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). - - **JSON example:** - - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + google.api_core.operation.Operation: + An object representing a long-running operation. - **YAML example:** + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). + } """ # 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. - flattened_params = [resource] + flattened_params = [name] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -1996,24 +2093,23 @@ def sample_get_iam_policy_repo(): "the individual field arguments should be set." ) - if isinstance(request, dict): - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - request = iam_policy_pb2.GetIamPolicyRequest(**request) - elif not request: - # Null request, just make one. - request = iam_policy_pb2.GetIamPolicyRequest() - if resource is not None: - request.resource = resource + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.DeleteRepositoryRequest): + request = secure_source_manager.DeleteRepositoryRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_iam_policy_repo] + rpc = self._transport._wrapped_methods[self._transport.delete_repository] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Validate the universe domain. @@ -2027,19 +2123,4484 @@ def sample_get_iam_policy_repo(): metadata=metadata, ) - # Done; return the response. - return response - - def set_iam_policy_repo( - self, - request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, - *, + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_hooks( + self, + request: Optional[Union[secure_source_manager.ListHooksRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListHooksPager: + r"""Lists hooks in 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 import securesourcemanager_v1 + + def sample_list_hooks(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListHooksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_hooks(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.ListHooksRequest, dict]): + The request object. ListHooksRequest is request to list + hooks. + parent (str): + Required. Parent value for + ListHooksRequest. + + This corresponds to the ``parent`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListHooksPager: + ListHooksResponse is response to list + hooks. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.ListHooksRequest): + request = secure_source_manager.ListHooksRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_hooks] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListHooksPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_hook( + self, + request: Optional[Union[secure_source_manager.GetHookRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.Hook: + r"""Gets metadata of a hook. + + .. 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 import securesourcemanager_v1 + + def sample_get_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetHookRequest( + name="name_value", + ) + + # Make the request + response = client.get_hook(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.GetHookRequest, dict]): + The request object. GetHookRequest is the request for + getting a hook. + name (str): + Required. Name of the hook to retrieve. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/hooks/{hook_id}``. + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.types.Hook: + Metadata of a Secure Source Manager + Hook. + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.GetHookRequest): + request = secure_source_manager.GetHookRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_hook] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_hook( + self, + request: Optional[Union[secure_source_manager.CreateHookRequest, dict]] = None, + *, + parent: Optional[str] = None, + hook: Optional[secure_source_manager.Hook] = None, + hook_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates a new hook in 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 import securesourcemanager_v1 + + def sample_create_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + hook = securesourcemanager_v1.Hook() + hook.target_uri = "target_uri_value" + + request = securesourcemanager_v1.CreateHookRequest( + parent="parent_value", + hook=hook, + hook_id="hook_id_value", + ) + + # Make the request + operation = client.create_hook(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.CreateHookRequest, dict]): + The request object. CreateHookRequest is the request for + creating a hook. + parent (str): + Required. The repository in which to create the hook. + Values are of the form + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + hook (google.cloud.securesourcemanager_v1.types.Hook): + Required. The resource being created. + This corresponds to the ``hook`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + hook_id (str): + Required. The ID to use for the hook, + which will become the final component of + the hook's resource name. This value + restricts to lower-case letters, + numbers, and hyphen, with the first + character a letter, the last a letter or + a number, and a 63 character maximum. + + This corresponds to the ``hook_id`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Hook` + Metadata of a Secure Source Manager Hook. + + """ + # 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. + flattened_params = [parent, hook, hook_id] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.CreateHookRequest): + request = secure_source_manager.CreateHookRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if hook is not None: + request.hook = hook + if hook_id is not None: + request.hook_id = hook_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_hook] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.Hook, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_hook( + self, + request: Optional[Union[secure_source_manager.UpdateHookRequest, dict]] = None, + *, + hook: Optional[secure_source_manager.Hook] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates the metadata of a hook. + + .. 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 import securesourcemanager_v1 + + def sample_update_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + hook = securesourcemanager_v1.Hook() + hook.target_uri = "target_uri_value" + + request = securesourcemanager_v1.UpdateHookRequest( + hook=hook, + ) + + # Make the request + operation = client.update_hook(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.UpdateHookRequest, dict]): + The request object. UpdateHookRequest is the request to + update a hook. + hook (google.cloud.securesourcemanager_v1.types.Hook): + Required. The hook being updated. + This corresponds to the ``hook`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the hook resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. The special value "*" + means full replacement. + + This corresponds to the ``update_mask`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Hook` + Metadata of a Secure Source Manager Hook. + + """ + # 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. + flattened_params = [hook, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.UpdateHookRequest): + request = secure_source_manager.UpdateHookRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if hook is not None: + request.hook = hook + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_hook] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("hook.name", request.hook.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.Hook, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_hook( + self, + request: Optional[Union[secure_source_manager.DeleteHookRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deletes a Hook. + + .. 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 import securesourcemanager_v1 + + def sample_delete_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeleteHookRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_hook(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.DeleteHookRequest, dict]): + The request object. DeleteHookRequest is the request to + delete a hook. + name (str): + Required. Name of the hook to delete. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/hooks/{hook_id}``. + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.DeleteHookRequest): + request = secure_source_manager.DeleteHookRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_hook] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_iam_policy_repo( + self, + request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None, + *, + resource: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> policy_pb2.Policy: + r"""Get IAM policy for a 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 import securesourcemanager_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + def sample_get_iam_policy_repo(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy_repo(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): + The request object. Request message for ``GetIamPolicy`` method. + resource (str): + REQUIRED: The resource for which the + policy is being requested. See the + operation documentation for the + appropriate value for this field. + + This corresponds to the ``resource`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.iam.v1.policy_pb2.Policy: + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. + + A Policy is a collection of bindings. A binding binds + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** + + :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + + **YAML example:** + + :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + + For a description of IAM and its features, see the + [IAM + documentation](\ https://cloud.google.com/iam/docs/). + + """ + # 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. + flattened_params = [resource] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = iam_policy_pb2.GetIamPolicyRequest(**request) + elif not request: + # Null request, just make one. + request = iam_policy_pb2.GetIamPolicyRequest() + if resource is not None: + request.resource = resource + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_iam_policy_repo] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def set_iam_policy_repo( + self, + request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None, + *, + resource: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> policy_pb2.Policy: + r"""Set IAM policy on a 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 import securesourcemanager_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + def sample_set_iam_policy_repo(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy_repo(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): + The request object. Request message for ``SetIamPolicy`` method. + resource (str): + REQUIRED: The resource for which the + policy is being specified. See the + operation documentation for the + appropriate value for this field. + + This corresponds to the ``resource`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.iam.v1.policy_pb2.Policy: + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. + + A Policy is a collection of bindings. A binding binds + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** + + :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + + **YAML example:** + + :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + + For a description of IAM and its features, see the + [IAM + documentation](\ https://cloud.google.com/iam/docs/). + + """ + # 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. + flattened_params = [resource] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = iam_policy_pb2.SetIamPolicyRequest(**request) + elif not request: + # Null request, just make one. + request = iam_policy_pb2.SetIamPolicyRequest() + if resource is not None: + request.resource = resource + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.set_iam_policy_repo] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def test_iam_permissions_repo( + self, + request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, + *, resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> policy_pb2.Policy: - r"""Set IAM policy on a repository. + ) -> iam_policy_pb2.TestIamPermissionsResponse: + r"""Test IAM permissions on a repository. + IAM permission checks are not required on this method. + + .. 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 import securesourcemanager_v1 + from google.iam.v1 import iam_policy_pb2 # type: ignore + + def sample_test_iam_permissions_repo(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = client.test_iam_permissions_repo(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): + The request object. Request message for ``TestIamPermissions`` method. + resource (str): + REQUIRED: The resource for which the + policy detail is being requested. See + the operation documentation for the + appropriate value for this field. + + This corresponds to the ``resource`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: + Response message for TestIamPermissions method. + """ + # 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. + flattened_params = [resource] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = iam_policy_pb2.TestIamPermissionsRequest(**request) + elif not request: + # Null request, just make one. + request = iam_policy_pb2.TestIamPermissionsRequest() + if resource is not None: + request.resource = resource + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.test_iam_permissions_repo + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_branch_rule( + self, + request: Optional[ + Union[secure_source_manager.CreateBranchRuleRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + branch_rule: Optional[secure_source_manager.BranchRule] = None, + branch_rule_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""CreateBranchRule creates a branch rule in 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 import securesourcemanager_v1 + + def sample_create_branch_rule(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.CreateBranchRuleRequest( + parent="parent_value", + branch_rule_id="branch_rule_id_value", + ) + + # Make the request + operation = client.create_branch_rule(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.CreateBranchRuleRequest, dict]): + The request object. CreateBranchRuleRequest is the + request to create a branch rule. + parent (str): + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + branch_rule (google.cloud.securesourcemanager_v1.types.BranchRule): + + This corresponds to the ``branch_rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + branch_rule_id (str): + + This corresponds to the ``branch_rule_id`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.BranchRule` Metadata of a BranchRule. BranchRule is the protection rule to enforce + pre-defined rules on designated branches within a + repository. + + """ + # 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. + flattened_params = [parent, branch_rule, branch_rule_id] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.CreateBranchRuleRequest): + request = secure_source_manager.CreateBranchRuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if branch_rule is not None: + request.branch_rule = branch_rule + if branch_rule_id is not None: + request.branch_rule_id = branch_rule_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_branch_rule] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.BranchRule, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_branch_rules( + self, + request: Optional[ + Union[secure_source_manager.ListBranchRulesRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListBranchRulesPager: + r"""ListBranchRules lists branch rules in 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 import securesourcemanager_v1 + + def sample_list_branch_rules(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListBranchRulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_branch_rules(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.ListBranchRulesRequest, dict]): + The request object. ListBranchRulesRequest is the request + to list branch rules. + parent (str): + + This corresponds to the ``parent`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListBranchRulesPager: + ListBranchRulesResponse is the + response to listing branchRules. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.ListBranchRulesRequest): + request = secure_source_manager.ListBranchRulesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_branch_rules] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListBranchRulesPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_branch_rule( + self, + request: Optional[ + Union[secure_source_manager.GetBranchRuleRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.BranchRule: + r"""GetBranchRule gets a branch rule. + + .. 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 import securesourcemanager_v1 + + def sample_get_branch_rule(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetBranchRuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_branch_rule(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.GetBranchRuleRequest, dict]): + The request object. GetBranchRuleRequest is the request + for getting a branch rule. + name (str): + Required. Name of the repository to retrieve. The format + is + ``projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}``. + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.types.BranchRule: + Metadata of a BranchRule. BranchRule + is the protection rule to enforce + pre-defined rules on designated branches + within a repository. + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.GetBranchRuleRequest): + request = secure_source_manager.GetBranchRuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_branch_rule] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_branch_rule( + self, + request: Optional[ + Union[secure_source_manager.UpdateBranchRuleRequest, dict] + ] = None, + *, + branch_rule: Optional[secure_source_manager.BranchRule] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""UpdateBranchRule updates a branch rule. + + .. 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 import securesourcemanager_v1 + + def sample_update_branch_rule(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.UpdateBranchRuleRequest( + ) + + # Make the request + operation = client.update_branch_rule(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.UpdateBranchRuleRequest, dict]): + The request object. UpdateBranchRuleRequest is the + request to update a branchRule. + branch_rule (google.cloud.securesourcemanager_v1.types.BranchRule): + + This corresponds to the ``branch_rule`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the branchRule resource by the update. + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. The special value "*" + means full replacement. + + This corresponds to the ``update_mask`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.BranchRule` Metadata of a BranchRule. BranchRule is the protection rule to enforce + pre-defined rules on designated branches within a + repository. + + """ + # 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. + flattened_params = [branch_rule, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.UpdateBranchRuleRequest): + request = secure_source_manager.UpdateBranchRuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if branch_rule is not None: + request.branch_rule = branch_rule + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_branch_rule] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("branch_rule.name", request.branch_rule.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.BranchRule, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_branch_rule( + self, + request: Optional[ + Union[secure_source_manager.DeleteBranchRuleRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""DeleteBranchRule deletes a branch rule. + + .. 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 import securesourcemanager_v1 + + def sample_delete_branch_rule(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeleteBranchRuleRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_branch_rule(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.DeleteBranchRuleRequest, dict]): + The request object. DeleteBranchRuleRequest is the + request to delete a branch rule. + name (str): + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.DeleteBranchRuleRequest): + request = secure_source_manager.DeleteBranchRuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_branch_rule] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_pull_request( + self, + request: Optional[ + Union[secure_source_manager.CreatePullRequestRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + pull_request: Optional[secure_source_manager.PullRequest] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates a pull request. + + .. 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 import securesourcemanager_v1 + + def sample_create_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + pull_request = securesourcemanager_v1.PullRequest() + pull_request.title = "title_value" + pull_request.base.ref = "ref_value" + + request = securesourcemanager_v1.CreatePullRequestRequest( + parent="parent_value", + pull_request=pull_request, + ) + + # Make the request + operation = client.create_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.CreatePullRequestRequest, dict]): + The request object. CreatePullRequestRequest is the + request to create a pull request. + parent (str): + Required. The repository that the pull request is + created from. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + pull_request (google.cloud.securesourcemanager_v1.types.PullRequest): + Required. The pull request to create. + This corresponds to the ``pull_request`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.PullRequest` Metadata of a PullRequest. PullRequest is the request + from a user to merge a branch (head) into another + branch (base). + + """ + # 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. + flattened_params = [parent, pull_request] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.CreatePullRequestRequest): + request = secure_source_manager.CreatePullRequestRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if pull_request is not None: + request.pull_request = pull_request + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_pull_request] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.PullRequest, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_pull_request( + self, + request: Optional[ + Union[secure_source_manager.GetPullRequestRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.PullRequest: + r"""Gets a pull request. + + .. 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 import securesourcemanager_v1 + + def sample_get_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetPullRequestRequest( + name="name_value", + ) + + # Make the request + response = client.get_pull_request(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.GetPullRequestRequest, dict]): + The request object. GetPullRequestRequest is the request + to get a pull request. + name (str): + Required. Name of the pull request to retrieve. The + format is + ``projects/{project}/locations/{location}/repositories/{repository}/pullRequests/{pull_request}``. + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.types.PullRequest: + Metadata of a PullRequest. + PullRequest is the request from a user + to merge a branch (head) into another + branch (base). + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.GetPullRequestRequest): + request = secure_source_manager.GetPullRequestRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_pull_request] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_pull_requests( + self, + request: Optional[ + Union[secure_source_manager.ListPullRequestsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListPullRequestsPager: + r"""Lists pull requests in a 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 import securesourcemanager_v1 + + def sample_list_pull_requests(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListPullRequestsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pull_requests(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.ListPullRequestsRequest, dict]): + The request object. ListPullRequestsRequest is the + request to list pull requests. + parent (str): + Required. The repository in which to list pull requests. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + + This corresponds to the ``parent`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListPullRequestsPager: + ListPullRequestsResponse is the + response to list pull requests. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.ListPullRequestsRequest): + request = secure_source_manager.ListPullRequestsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_pull_requests] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListPullRequestsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_pull_request( + self, + request: Optional[ + Union[secure_source_manager.UpdatePullRequestRequest, dict] + ] = None, + *, + pull_request: Optional[secure_source_manager.PullRequest] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates a pull request. + + .. 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 import securesourcemanager_v1 + + def sample_update_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + pull_request = securesourcemanager_v1.PullRequest() + pull_request.title = "title_value" + pull_request.base.ref = "ref_value" + + request = securesourcemanager_v1.UpdatePullRequestRequest( + pull_request=pull_request, + ) + + # Make the request + operation = client.update_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.UpdatePullRequestRequest, dict]): + The request object. UpdatePullRequestRequest is the + request to update a pull request. + pull_request (google.cloud.securesourcemanager_v1.types.PullRequest): + Required. The pull request to update. + This corresponds to the ``pull_request`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the pull request resource by the update. + The fields specified in the update_mask are relative to + the resource, not the full request. A field will be + overwritten if it is in the mask. The special value "*" + means full replacement. + + This corresponds to the ``update_mask`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.PullRequest` Metadata of a PullRequest. PullRequest is the request + from a user to merge a branch (head) into another + branch (base). + + """ + # 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. + flattened_params = [pull_request, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.UpdatePullRequestRequest): + request = secure_source_manager.UpdatePullRequestRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if pull_request is not None: + request.pull_request = pull_request + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_pull_request] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("pull_request.name", request.pull_request.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.PullRequest, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def merge_pull_request( + self, + request: Optional[ + Union[secure_source_manager.MergePullRequestRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Merges a pull request. + + .. 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 import securesourcemanager_v1 + + def sample_merge_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.MergePullRequestRequest( + name="name_value", + ) + + # Make the request + operation = client.merge_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.MergePullRequestRequest, dict]): + The request object. MergePullRequestRequest is the + request to merge a pull request. + name (str): + Required. The pull request to merge. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.PullRequest` Metadata of a PullRequest. PullRequest is the request + from a user to merge a branch (head) into another + branch (base). + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.MergePullRequestRequest): + request = secure_source_manager.MergePullRequestRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.merge_pull_request] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.PullRequest, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def open_pull_request( + self, + request: Optional[ + Union[secure_source_manager.OpenPullRequestRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Opens a pull request. + + .. 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 import securesourcemanager_v1 + + def sample_open_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.OpenPullRequestRequest( + name="name_value", + ) + + # Make the request + operation = client.open_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.OpenPullRequestRequest, dict]): + The request object. OpenPullRequestRequest is the request + to open a pull request. + name (str): + Required. The pull request to open. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.PullRequest` Metadata of a PullRequest. PullRequest is the request + from a user to merge a branch (head) into another + branch (base). + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.OpenPullRequestRequest): + request = secure_source_manager.OpenPullRequestRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.open_pull_request] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.PullRequest, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def close_pull_request( + self, + request: Optional[ + Union[secure_source_manager.ClosePullRequestRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Closes a pull request without merging. + + .. 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 import securesourcemanager_v1 + + def sample_close_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ClosePullRequestRequest( + name="name_value", + ) + + # Make the request + operation = client.close_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.ClosePullRequestRequest, dict]): + The request object. ClosePullRequestRequest is the + request to close a pull request. + name (str): + Required. The pull request to close. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.PullRequest` Metadata of a PullRequest. PullRequest is the request + from a user to merge a branch (head) into another + branch (base). + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.ClosePullRequestRequest): + request = secure_source_manager.ClosePullRequestRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.close_pull_request] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.PullRequest, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_pull_request_file_diffs( + self, + request: Optional[ + Union[secure_source_manager.ListPullRequestFileDiffsRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListPullRequestFileDiffsPager: + r"""Lists a pull request's file diffs. + + .. 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 import securesourcemanager_v1 + + def sample_list_pull_request_file_diffs(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListPullRequestFileDiffsRequest( + name="name_value", + ) + + # Make the request + page_result = client.list_pull_request_file_diffs(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.ListPullRequestFileDiffsRequest, dict]): + The request object. ListPullRequestFileDiffsRequest is + the request to list pull request file + diffs. + name (str): + Required. The pull request to list file diffs for. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListPullRequestFileDiffsPager: + ListPullRequestFileDiffsResponse is + the response containing file diffs + returned from ListPullRequestFileDiffs. + + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.ListPullRequestFileDiffsRequest + ): + request = secure_source_manager.ListPullRequestFileDiffsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.list_pull_request_file_diffs + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListPullRequestFileDiffsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def fetch_tree( + self, + request: Optional[Union[secure_source_manager.FetchTreeRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.FetchTreePager: + r"""Fetches a tree from a 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 import securesourcemanager_v1 + + def sample_fetch_tree(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.FetchTreeRequest( + repository="repository_value", + ) + + # Make the request + page_result = client.fetch_tree(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.FetchTreeRequest, dict]): + The request object. Request message for fetching a tree + structure from a repository. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.FetchTreePager: + Response message containing a list of + TreeEntry objects. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # Create or coerce a protobuf request object. + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.FetchTreeRequest): + request = secure_source_manager.FetchTreeRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.fetch_tree] + + # 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),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.FetchTreePager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def fetch_blob( + self, + request: Optional[Union[secure_source_manager.FetchBlobRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.FetchBlobResponse: + r"""Fetches a blob from a 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 import securesourcemanager_v1 + + def sample_fetch_blob(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.FetchBlobRequest( + repository="repository_value", + sha="sha_value", + ) + + # Make the request + response = client.fetch_blob(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.FetchBlobRequest, dict]): + The request object. Request message for fetching a blob + (file content) from a repository. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.types.FetchBlobResponse: + Response message containing the + content of a blob. + + """ + # Create or coerce a protobuf request object. + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.FetchBlobRequest): + request = secure_source_manager.FetchBlobRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.fetch_blob] + + # 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),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_issue( + self, + request: Optional[Union[secure_source_manager.CreateIssueRequest, dict]] = None, + *, + parent: Optional[str] = None, + issue: Optional[secure_source_manager.Issue] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates an issue. + + .. 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 import securesourcemanager_v1 + + def sample_create_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + issue = securesourcemanager_v1.Issue() + issue.title = "title_value" + + request = securesourcemanager_v1.CreateIssueRequest( + parent="parent_value", + issue=issue, + ) + + # Make the request + operation = client.create_issue(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.CreateIssueRequest, dict]): + The request object. The request to create an issue. + parent (str): + Required. The repository in which to create the issue. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + issue (google.cloud.securesourcemanager_v1.types.Issue): + Required. The issue to create. + This corresponds to the ``issue`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Issue` + Metadata of an Issue. + + """ + # 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. + flattened_params = [parent, issue] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.CreateIssueRequest): + request = secure_source_manager.CreateIssueRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if issue is not None: + request.issue = issue + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_issue] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.Issue, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_issue( + self, + request: Optional[Union[secure_source_manager.GetIssueRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.Issue: + r"""Gets an issue. + + .. 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 import securesourcemanager_v1 + + def sample_get_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetIssueRequest( + name="name_value", + ) + + # Make the request + response = client.get_issue(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.GetIssueRequest, dict]): + The request object. The request to get an issue. + name (str): + Required. Name of the issue to retrieve. The format is + ``projects/{project}/locations/{location}/repositories/{repository}/issues/{issue_id}``. + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.types.Issue: + Metadata of an Issue. + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.GetIssueRequest): + request = secure_source_manager.GetIssueRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_issue] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_issues( + self, + request: Optional[Union[secure_source_manager.ListIssuesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListIssuesPager: + r"""Lists issues in a 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 import securesourcemanager_v1 + + def sample_list_issues(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListIssuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_issues(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.ListIssuesRequest, dict]): + The request object. The request to list issues. + parent (str): + Required. The repository in which to list issues. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + + This corresponds to the ``parent`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListIssuesPager: + The response to list issues. + + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.ListIssuesRequest): + request = secure_source_manager.ListIssuesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_issues] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListIssuesPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_issue( + self, + request: Optional[Union[secure_source_manager.UpdateIssueRequest, dict]] = None, + *, + issue: Optional[secure_source_manager.Issue] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates a issue. + + .. 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 import securesourcemanager_v1 + + def sample_update_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + issue = securesourcemanager_v1.Issue() + issue.title = "title_value" + + request = securesourcemanager_v1.UpdateIssueRequest( + issue=issue, + ) + + # Make the request + operation = client.update_issue(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.UpdateIssueRequest, dict]): + The request object. The request to update an issue. + issue (google.cloud.securesourcemanager_v1.types.Issue): + Required. The issue to update. + This corresponds to the ``issue`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the issue resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be + overwritten if it is in the mask. The special value "*" + means full replacement. + + This corresponds to the ``update_mask`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Issue` + Metadata of an Issue. + + """ + # 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. + flattened_params = [issue, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.UpdateIssueRequest): + request = secure_source_manager.UpdateIssueRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue is not None: + request.issue = issue + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_issue] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("issue.name", request.issue.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.Issue, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_issue( + self, + request: Optional[Union[secure_source_manager.DeleteIssueRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deletes an issue. + + .. 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 import securesourcemanager_v1 + + def sample_delete_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeleteIssueRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_issue(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.DeleteIssueRequest, dict]): + The request object. The request to delete an issue. + name (str): + Required. Name of the issue to delete. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}``. + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.DeleteIssueRequest): + request = secure_source_manager.DeleteIssueRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_issue] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def open_issue( + self, + request: Optional[Union[secure_source_manager.OpenIssueRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Opens an issue. + + .. 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 import securesourcemanager_v1 + + def sample_open_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.OpenIssueRequest( + name="name_value", + ) + + # Make the request + operation = client.open_issue(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.OpenIssueRequest, dict]): + The request object. The request to open an issue. + name (str): + Required. Name of the issue to open. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}``. + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Issue` + Metadata of an Issue. + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.OpenIssueRequest): + request = secure_source_manager.OpenIssueRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.open_issue] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.Issue, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def close_issue( + self, + request: Optional[Union[secure_source_manager.CloseIssueRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Closes an issue. + + .. 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 import securesourcemanager_v1 + + def sample_close_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.CloseIssueRequest( + name="name_value", + ) + + # Make the request + operation = client.close_issue(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.CloseIssueRequest, dict]): + The request object. The request to close an issue. + name (str): + Required. Name of the issue to close. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}``. + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.Issue` + Metadata of an Issue. + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.CloseIssueRequest): + request = secure_source_manager.CloseIssueRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.close_issue] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.Issue, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def get_pull_request_comment( + self, + request: Optional[ + Union[secure_source_manager.GetPullRequestCommentRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.PullRequestComment: + r"""Gets a pull request comment. + + .. 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 import securesourcemanager_v1 + + def sample_get_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetPullRequestCommentRequest( + name="name_value", + ) + + # Make the request + response = client.get_pull_request_comment(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.GetPullRequestCommentRequest, dict]): + The request object. The request to get a pull request + comment. + name (str): + Required. Name of the pull request comment to retrieve. + The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}/pullRequestComments/{comment_id}``. + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.types.PullRequestComment: + PullRequestComment represents a + comment on a pull request. + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, secure_source_manager.GetPullRequestCommentRequest): + request = secure_source_manager.GetPullRequestCommentRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_pull_request_comment] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_pull_request_comments( + self, + request: Optional[ + Union[secure_source_manager.ListPullRequestCommentsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListPullRequestCommentsPager: + r"""Lists pull request comments. + + .. 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 import securesourcemanager_v1 + + def sample_list_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListPullRequestCommentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pull_request_comments(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.ListPullRequestCommentsRequest, dict]): + The request object. The request to list pull request + comments. + parent (str): + Required. The pull request in which to list pull request + comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``parent`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListPullRequestCommentsPager: + The response to list pull request + comments. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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. + flattened_params = [parent] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.ListPullRequestCommentsRequest + ): + request = secure_source_manager.ListPullRequestCommentsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.list_pull_request_comments + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListPullRequestCommentsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_pull_request_comment( + self, + request: Optional[ + Union[secure_source_manager.CreatePullRequestCommentRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + pull_request_comment: Optional[secure_source_manager.PullRequestComment] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates a pull request comment. + + .. 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 import securesourcemanager_v1 + + def sample_create_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + pull_request_comment = securesourcemanager_v1.PullRequestComment() + pull_request_comment.review.action_type = "APPROVED" + + request = securesourcemanager_v1.CreatePullRequestCommentRequest( + parent="parent_value", + pull_request_comment=pull_request_comment, + ) + + # Make the request + operation = client.create_pull_request_comment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.CreatePullRequestCommentRequest, dict]): + The request object. The request to create a pull request + comment. + parent (str): + Required. The pull request in which to create the pull + request comment. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + pull_request_comment (google.cloud.securesourcemanager_v1.types.PullRequestComment): + Required. The pull request comment to + create. + + This corresponds to the ``pull_request_comment`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.PullRequestComment` + PullRequestComment represents a comment on a pull + request. + + """ + # 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. + flattened_params = [parent, pull_request_comment] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.CreatePullRequestCommentRequest + ): + request = secure_source_manager.CreatePullRequestCommentRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if pull_request_comment is not None: + request.pull_request_comment = pull_request_comment + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.create_pull_request_comment + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.PullRequestComment, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_pull_request_comment( + self, + request: Optional[ + Union[secure_source_manager.UpdatePullRequestCommentRequest, dict] + ] = None, + *, + pull_request_comment: Optional[secure_source_manager.PullRequestComment] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates a pull request comment. + + .. 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 import securesourcemanager_v1 + + def sample_update_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + pull_request_comment = securesourcemanager_v1.PullRequestComment() + pull_request_comment.review.action_type = "APPROVED" + + request = securesourcemanager_v1.UpdatePullRequestCommentRequest( + pull_request_comment=pull_request_comment, + ) + + # Make the request + operation = client.update_pull_request_comment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.UpdatePullRequestCommentRequest, dict]): + The request object. The request to update a pull request + comment. + pull_request_comment (google.cloud.securesourcemanager_v1.types.PullRequestComment): + Required. The pull request comment to + update. + + This corresponds to the ``pull_request_comment`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the pull request comment resource by the + update. Updatable fields are ``body``. + + This corresponds to the ``update_mask`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.PullRequestComment` + PullRequestComment represents a comment on a pull + request. + + """ + # 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. + flattened_params = [pull_request_comment, update_mask] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.UpdatePullRequestCommentRequest + ): + request = secure_source_manager.UpdatePullRequestCommentRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if pull_request_comment is not None: + request.pull_request_comment = pull_request_comment + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.update_pull_request_comment + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("pull_request_comment.name", request.pull_request_comment.name),) + ), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.PullRequestComment, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_pull_request_comment( + self, + request: Optional[ + Union[secure_source_manager.DeletePullRequestCommentRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deletes a pull request comment. + + .. 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 import securesourcemanager_v1 + + def sample_delete_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeletePullRequestCommentRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_pull_request_comment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.DeletePullRequestCommentRequest, dict]): + The request object. The request to delete a pull request + comment. A Review PullRequestComment + cannot be deleted. + name (str): + Required. Name of the pull request comment to delete. + The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}/pullRequestComments/{comment_id}``. + + This corresponds to the ``name`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + """ + # 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. + flattened_params = [name] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.DeletePullRequestCommentRequest + ): + request = secure_source_manager.DeletePullRequestCommentRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.delete_pull_request_comment + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + empty_pb2.Empty, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def batch_create_pull_request_comments( + self, + request: Optional[ + Union[secure_source_manager.BatchCreatePullRequestCommentsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + requests: Optional[ + MutableSequence[secure_source_manager.CreatePullRequestCommentRequest] + ] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Batch creates pull request comments. .. code-block:: python @@ -2051,33 +6612,54 @@ def set_iam_policy_repo( # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_set_iam_policy_repo(): + def sample_batch_create_pull_request_comments(): # Create a client client = securesourcemanager_v1.SecureSourceManagerClient() # Initialize request argument(s) - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", + requests = securesourcemanager_v1.CreatePullRequestCommentRequest() + requests.parent = "parent_value" + requests.pull_request_comment.review.action_type = "APPROVED" + + request = securesourcemanager_v1.BatchCreatePullRequestCommentsRequest( + parent="parent_value", + requests=requests, ) # Make the request - response = client.set_iam_policy_repo(request=request) + operation = client.batch_create_pull_request_comments(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() # Handle the response print(response) Args: - request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): - The request object. Request message for ``SetIamPolicy`` method. - resource (str): - REQUIRED: The resource for which the - policy is being specified. See the - operation documentation for the - appropriate value for this field. + request (Union[google.cloud.securesourcemanager_v1.types.BatchCreatePullRequestCommentsRequest, dict]): + The request object. The request to batch create pull + request comments. + parent (str): + Required. The pull request in which to create the pull + request comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` - This corresponds to the ``resource`` field + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + requests (MutableSequence[google.cloud.securesourcemanager_v1.types.CreatePullRequestCommentRequest]): + Required. The request message + specifying the resources to create. + There should be exactly one + CreatePullRequestCommentRequest with + CommentDetail being REVIEW in the list, + and no more than 100 + CreatePullRequestCommentRequests with + CommentDetail being CODE in the list + + This corresponds to the ``requests`` 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, @@ -2089,43 +6671,164 @@ def sample_set_iam_policy_repo(): be of type `bytes`. Returns: - google.iam.v1.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which specifies access - controls for Google Cloud resources. + google.api_core.operation.Operation: + An object representing a long-running operation. - A Policy is a collection of bindings. A binding binds - one or more members, or principals, to a single role. - Principals can be user accounts, service accounts, - Google groups, and domains (such as G Suite). A role - is a named list of permissions; each role can be an - IAM predefined role or a user-created custom role. + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.BatchCreatePullRequestCommentsResponse` + The response to batch create pull request comments. - For some types of Google Cloud resources, a binding - can also specify a condition, which is a logical - expression that allows access to a resource only if - the expression evaluates to true. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the [IAM - documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + """ + # 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. + flattened_params = [parent, requests] + has_flattened_params = ( + len([param for param in flattened_params if param is not None]) > 0 + ) + 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." + ) - **JSON example:** + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.BatchCreatePullRequestCommentsRequest + ): + request = secure_source_manager.BatchCreatePullRequestCommentsRequest( + request + ) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if requests is not None: + request.requests = requests - :literal:`\` { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }`\ \` + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.batch_create_pull_request_comments + ] - **YAML example:** + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) - :literal:`\` bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3`\ \` + # Validate the universe domain. + self._validate_universe_domain() - For a description of IAM and its features, see the - [IAM - documentation](\ https://cloud.google.com/iam/docs/). + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.BatchCreatePullRequestCommentsResponse, + metadata_type=secure_source_manager.OperationMetadata, + ) + + # Done; return the response. + return response + + def resolve_pull_request_comments( + self, + request: Optional[ + Union[secure_source_manager.ResolvePullRequestCommentsRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + names: Optional[MutableSequence[str]] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Resolves pull request comments. + + .. 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 import securesourcemanager_v1 + + def sample_resolve_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ResolvePullRequestCommentsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], + ) + + # Make the request + operation = client.resolve_pull_request_comments(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securesourcemanager_v1.types.ResolvePullRequestCommentsRequest, dict]): + The request object. The request to resolve multiple pull + request comments. + parent (str): + Required. The pull request in which to resolve the pull + request comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + names (MutableSequence[str]): + Required. The names of the pull request comments to + resolve. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}/pullRequestComments/{comment_id}`` + Only comments from the same threads are allowed in the + same request. + + This corresponds to the ``names`` 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.ResolvePullRequestCommentsResponse` + The response to resolve multiple pull request comments. """ # 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. - flattened_params = [resource] + flattened_params = [parent, names] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -2135,24 +6838,29 @@ def sample_set_iam_policy_repo(): "the individual field arguments should be set." ) - if isinstance(request, dict): - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - request = iam_policy_pb2.SetIamPolicyRequest(**request) - elif not request: - # Null request, just make one. - request = iam_policy_pb2.SetIamPolicyRequest() - if resource is not None: - request.resource = resource + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.ResolvePullRequestCommentsRequest + ): + request = secure_source_manager.ResolvePullRequestCommentsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if names is not None: + request.names = names # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.set_iam_policy_repo] + rpc = self._transport._wrapped_methods[ + self._transport.resolve_pull_request_comments + ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -2166,20 +6874,30 @@ def sample_set_iam_policy_repo(): metadata=metadata, ) + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.ResolvePullRequestCommentsResponse, + metadata_type=secure_source_manager.OperationMetadata, + ) + # Done; return the response. return response - def test_iam_permissions_repo( + def unresolve_pull_request_comments( self, - request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None, + request: Optional[ + Union[secure_source_manager.UnresolvePullRequestCommentsRequest, dict] + ] = None, *, - resource: Optional[str] = None, + parent: Optional[str] = None, + names: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Test IAM permissions on a repository. - IAM permission checks are not required on this method. + ) -> operation.Operation: + r"""Unresolves pull request comment. .. code-block:: python @@ -2191,34 +6909,47 @@ def test_iam_permissions_repo( # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_test_iam_permissions_repo(): + def sample_unresolve_pull_request_comments(): # Create a client client = securesourcemanager_v1.SecureSourceManagerClient() # Initialize request argument(s) - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", - permissions=['permissions_value1', 'permissions_value2'], + request = securesourcemanager_v1.UnresolvePullRequestCommentsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], ) # Make the request - response = client.test_iam_permissions_repo(request=request) + operation = client.unresolve_pull_request_comments(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() # Handle the response print(response) Args: - request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): - The request object. Request message for ``TestIamPermissions`` method. - resource (str): - REQUIRED: The resource for which the - policy detail is being requested. See - the operation documentation for the - appropriate value for this field. + request (Union[google.cloud.securesourcemanager_v1.types.UnresolvePullRequestCommentsRequest, dict]): + The request object. The request to unresolve multiple + pull request comments. + parent (str): + Required. The pull request in which to resolve the pull + request comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` - This corresponds to the ``resource`` field + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + names (MutableSequence[str]): + Required. The names of the pull request comments to + unresolve. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}/pullRequestComments/{comment_id}`` + Only comments from the same threads are allowed in the + same request. + + This corresponds to the ``names`` 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, @@ -2230,13 +6961,19 @@ def sample_test_iam_permissions_repo(): be of type `bytes`. Returns: - google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: - Response message for TestIamPermissions method. + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.UnresolvePullRequestCommentsResponse` + The response to unresolve multiple pull request + comments. + """ # 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. - flattened_params = [resource] + flattened_params = [parent, names] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -2246,26 +6983,29 @@ def sample_test_iam_permissions_repo(): "the individual field arguments should be set." ) - if isinstance(request, dict): - # - The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - request = iam_policy_pb2.TestIamPermissionsRequest(**request) - elif not request: - # Null request, just make one. - request = iam_policy_pb2.TestIamPermissionsRequest() - if resource is not None: - request.resource = resource + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, secure_source_manager.UnresolvePullRequestCommentsRequest + ): + request = secure_source_manager.UnresolvePullRequestCommentsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if names is not None: + request.names = names # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ - self._transport.test_iam_permissions_repo + self._transport.unresolve_pull_request_comments ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -2279,24 +7019,30 @@ def sample_test_iam_permissions_repo(): metadata=metadata, ) + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + secure_source_manager.UnresolvePullRequestCommentsResponse, + metadata_type=secure_source_manager.OperationMetadata, + ) + # Done; return the response. return response - def create_branch_rule( + def create_issue_comment( self, request: Optional[ - Union[secure_source_manager.CreateBranchRuleRequest, dict] + Union[secure_source_manager.CreateIssueCommentRequest, dict] ] = None, *, parent: Optional[str] = None, - branch_rule: Optional[secure_source_manager.BranchRule] = None, - branch_rule_id: Optional[str] = None, + issue_comment: Optional[secure_source_manager.IssueComment] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: - r"""CreateBranchRule creates a branch rule in a given - repository. + r"""Creates an issue comment. .. code-block:: python @@ -2309,18 +7055,21 @@ def create_branch_rule( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - def sample_create_branch_rule(): + def sample_create_issue_comment(): # Create a client client = securesourcemanager_v1.SecureSourceManagerClient() # Initialize request argument(s) - request = securesourcemanager_v1.CreateBranchRuleRequest( + issue_comment = securesourcemanager_v1.IssueComment() + issue_comment.body = "body_value" + + request = securesourcemanager_v1.CreateIssueCommentRequest( parent="parent_value", - branch_rule_id="branch_rule_id_value", + issue_comment=issue_comment, ) # Make the request - operation = client.create_branch_rule(request=request) + operation = client.create_issue_comment(request=request) print("Waiting for operation to complete...") @@ -2330,22 +7079,22 @@ def sample_create_branch_rule(): print(response) Args: - request (Union[google.cloud.securesourcemanager_v1.types.CreateBranchRuleRequest, dict]): - The request object. CreateBranchRuleRequest is the - request to create a branch rule. + request (Union[google.cloud.securesourcemanager_v1.types.CreateIssueCommentRequest, dict]): + The request object. The request to create an issue + comment. parent (str): + Required. The issue in which to create the issue + comment. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}`` This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - branch_rule (google.cloud.securesourcemanager_v1.types.BranchRule): - - This corresponds to the ``branch_rule`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - branch_rule_id (str): + issue_comment (google.cloud.securesourcemanager_v1.types.IssueComment): + Required. The issue comment to + create. - This corresponds to the ``branch_rule_id`` field + This corresponds to the ``issue_comment`` 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, @@ -2360,15 +7109,15 @@ def sample_create_branch_rule(): google.api_core.operation.Operation: An object representing a long-running operation. - The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.BranchRule` Metadata of a BranchRule. BranchRule is the protection rule to enforce - pre-defined rules on desginated branches within a - repository. + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.IssueComment` + IssueComment represents a comment on an issue. """ # 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. - flattened_params = [parent, branch_rule, branch_rule_id] + flattened_params = [parent, issue_comment] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -2380,20 +7129,18 @@ def sample_create_branch_rule(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, secure_source_manager.CreateBranchRuleRequest): - request = secure_source_manager.CreateBranchRuleRequest(request) + if not isinstance(request, secure_source_manager.CreateIssueCommentRequest): + request = secure_source_manager.CreateIssueCommentRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent - if branch_rule is not None: - request.branch_rule = branch_rule - if branch_rule_id is not None: - request.branch_rule_id = branch_rule_id + if issue_comment is not None: + request.issue_comment = issue_comment # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_branch_rule] + rpc = self._transport._wrapped_methods[self._transport.create_issue_comment] # Certain fields should be provided within the metadata header; # add these here. @@ -2416,26 +7163,25 @@ def sample_create_branch_rule(): response = operation.from_gapic( response, self._transport.operations_client, - secure_source_manager.BranchRule, + secure_source_manager.IssueComment, metadata_type=secure_source_manager.OperationMetadata, ) # Done; return the response. return response - def list_branch_rules( + def get_issue_comment( self, request: Optional[ - Union[secure_source_manager.ListBranchRulesRequest, dict] + Union[secure_source_manager.GetIssueCommentRequest, dict] ] = None, *, - parent: Optional[str] = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListBranchRulesPager: - r"""ListBranchRules lists branch rules in a given - repository. + ) -> secure_source_manager.IssueComment: + r"""Gets an issue comment. .. code-block:: python @@ -2448,29 +7194,30 @@ def list_branch_rules( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - def sample_list_branch_rules(): + def sample_get_issue_comment(): # Create a client client = securesourcemanager_v1.SecureSourceManagerClient() # Initialize request argument(s) - request = securesourcemanager_v1.ListBranchRulesRequest( - parent="parent_value", + request = securesourcemanager_v1.GetIssueCommentRequest( + name="name_value", ) # Make the request - page_result = client.list_branch_rules(request=request) + response = client.get_issue_comment(request=request) # Handle the response - for response in page_result: - print(response) + print(response) Args: - request (Union[google.cloud.securesourcemanager_v1.types.ListBranchRulesRequest, dict]): - The request object. ListBranchRulesRequest is the request - to list branch rules. - parent (str): + request (Union[google.cloud.securesourcemanager_v1.types.GetIssueCommentRequest, dict]): + The request object. The request to get an issue comment. + name (str): + Required. Name of the issue comment to retrieve. The + format is + ``projects/{project}/locations/{location}/repositories/{repository}/issues/{issue_id}/issueComments/{comment_id}``. - This corresponds to the ``parent`` field + This corresponds to the ``name`` 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, @@ -2482,18 +7229,15 @@ def sample_list_branch_rules(): be of type `bytes`. Returns: - google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListBranchRulesPager: - ListBranchRulesResponse is the - response to listing branchRules. - Iterating over this object will yield - results and resolve additional pages - automatically. + google.cloud.securesourcemanager_v1.types.IssueComment: + IssueComment represents a comment on + an issue. """ # 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. - flattened_params = [parent] + flattened_params = [name] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -2505,21 +7249,21 @@ def sample_list_branch_rules(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, secure_source_manager.ListBranchRulesRequest): - request = secure_source_manager.ListBranchRulesRequest(request) + if not isinstance(request, secure_source_manager.GetIssueCommentRequest): + request = secure_source_manager.GetIssueCommentRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: - request.parent = parent + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.list_branch_rules] + rpc = self._transport._wrapped_methods[self._transport.get_issue_comment] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), ) # Validate the universe domain. @@ -2533,32 +7277,21 @@ def sample_list_branch_rules(): metadata=metadata, ) - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.ListBranchRulesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - # Done; return the response. return response - def get_branch_rule( + def list_issue_comments( self, request: Optional[ - Union[secure_source_manager.GetBranchRuleRequest, dict] + Union[secure_source_manager.ListIssueCommentsRequest, dict] ] = None, *, - name: Optional[str] = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> secure_source_manager.BranchRule: - r"""GetBranchRule gets a branch rule. + ) -> pagers.ListIssueCommentsPager: + r"""Lists comments in an issue. .. code-block:: python @@ -2571,31 +7304,31 @@ def get_branch_rule( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - def sample_get_branch_rule(): + def sample_list_issue_comments(): # Create a client client = securesourcemanager_v1.SecureSourceManagerClient() # Initialize request argument(s) - request = securesourcemanager_v1.GetBranchRuleRequest( - name="name_value", + request = securesourcemanager_v1.ListIssueCommentsRequest( + parent="parent_value", ) # Make the request - response = client.get_branch_rule(request=request) + page_result = client.list_issue_comments(request=request) # Handle the response - print(response) + for response in page_result: + print(response) Args: - request (Union[google.cloud.securesourcemanager_v1.types.GetBranchRuleRequest, dict]): - The request object. GetBranchRuleRequest is the request - for getting a branch rule. - name (str): - Required. Name of the repository to retrieve. The format - is - ``projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}``. + request (Union[google.cloud.securesourcemanager_v1.types.ListIssueCommentsRequest, dict]): + The request object. The request to list issue comments. + parent (str): + Required. The issue in which to list the comments. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}`` - This corresponds to the ``name`` field + This corresponds to the ``parent`` 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, @@ -2607,17 +7340,18 @@ def sample_get_branch_rule(): be of type `bytes`. Returns: - google.cloud.securesourcemanager_v1.types.BranchRule: - Metadata of a BranchRule. BranchRule - is the protection rule to enforce - pre-defined rules on desginated branches - within a repository. + google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListIssueCommentsPager: + The response to list issue comments. + + Iterating over this object will yield + results and resolve additional pages + automatically. """ # 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. - flattened_params = [name] + flattened_params = [parent] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -2629,21 +7363,21 @@ def sample_get_branch_rule(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, secure_source_manager.GetBranchRuleRequest): - request = secure_source_manager.GetBranchRuleRequest(request) + if not isinstance(request, secure_source_manager.ListIssueCommentsRequest): + request = secure_source_manager.ListIssueCommentsRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: - request.name = name + if parent is not None: + request.parent = parent # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.get_branch_rule] + rpc = self._transport._wrapped_methods[self._transport.list_issue_comments] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), ) # Validate the universe domain. @@ -2657,22 +7391,33 @@ def sample_get_branch_rule(): metadata=metadata, ) + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListIssueCommentsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + # Done; return the response. return response - def update_branch_rule( + def update_issue_comment( self, request: Optional[ - Union[secure_source_manager.UpdateBranchRuleRequest, dict] + Union[secure_source_manager.UpdateIssueCommentRequest, dict] ] = None, *, - branch_rule: Optional[secure_source_manager.BranchRule] = None, + issue_comment: Optional[secure_source_manager.IssueComment] = None, update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: - r"""UpdateBranchRule updates a branch rule. + r"""Updates an issue comment. .. code-block:: python @@ -2685,16 +7430,20 @@ def update_branch_rule( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - def sample_update_branch_rule(): + def sample_update_issue_comment(): # Create a client client = securesourcemanager_v1.SecureSourceManagerClient() # Initialize request argument(s) - request = securesourcemanager_v1.UpdateBranchRuleRequest( + issue_comment = securesourcemanager_v1.IssueComment() + issue_comment.body = "body_value" + + request = securesourcemanager_v1.UpdateIssueCommentRequest( + issue_comment=issue_comment, ) # Make the request - operation = client.update_branch_rule(request=request) + operation = client.update_issue_comment(request=request) print("Waiting for operation to complete...") @@ -2704,17 +7453,19 @@ def sample_update_branch_rule(): print(response) Args: - request (Union[google.cloud.securesourcemanager_v1.types.UpdateBranchRuleRequest, dict]): - The request object. UpdateBranchRuleRequest is the - request to update a branchRule. - branch_rule (google.cloud.securesourcemanager_v1.types.BranchRule): - - This corresponds to the ``branch_rule`` field + request (Union[google.cloud.securesourcemanager_v1.types.UpdateIssueCommentRequest, dict]): + The request object. The request to update an issue + comment. + issue_comment (google.cloud.securesourcemanager_v1.types.IssueComment): + Required. The issue comment to + update. + + This corresponds to the ``issue_comment`` field on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the branchRule resource by the update. + Optional. Field mask is used to specify the fields to be + overwritten in the issue comment resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. The special value "*" @@ -2735,15 +7486,15 @@ def sample_update_branch_rule(): google.api_core.operation.Operation: An object representing a long-running operation. - The result type for the operation will be :class:`google.cloud.securesourcemanager_v1.types.BranchRule` Metadata of a BranchRule. BranchRule is the protection rule to enforce - pre-defined rules on desginated branches within a - repository. + The result type for the operation will be + :class:`google.cloud.securesourcemanager_v1.types.IssueComment` + IssueComment represents a comment on an issue. """ # 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. - flattened_params = [branch_rule, update_mask] + flattened_params = [issue_comment, update_mask] has_flattened_params = ( len([param for param in flattened_params if param is not None]) > 0 ) @@ -2755,24 +7506,24 @@ def sample_update_branch_rule(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, secure_source_manager.UpdateBranchRuleRequest): - request = secure_source_manager.UpdateBranchRuleRequest(request) + if not isinstance(request, secure_source_manager.UpdateIssueCommentRequest): + request = secure_source_manager.UpdateIssueCommentRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. - if branch_rule is not None: - request.branch_rule = branch_rule + if issue_comment is not None: + request.issue_comment = issue_comment if update_mask is not None: request.update_mask = update_mask # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.update_branch_rule] + rpc = self._transport._wrapped_methods[self._transport.update_issue_comment] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( - (("branch_rule.name", request.branch_rule.name),) + (("issue_comment.name", request.issue_comment.name),) ), ) @@ -2791,17 +7542,17 @@ def sample_update_branch_rule(): response = operation.from_gapic( response, self._transport.operations_client, - secure_source_manager.BranchRule, + secure_source_manager.IssueComment, metadata_type=secure_source_manager.OperationMetadata, ) # Done; return the response. return response - def delete_branch_rule( + def delete_issue_comment( self, request: Optional[ - Union[secure_source_manager.DeleteBranchRuleRequest, dict] + Union[secure_source_manager.DeleteIssueCommentRequest, dict] ] = None, *, name: Optional[str] = None, @@ -2809,7 +7560,7 @@ def delete_branch_rule( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: - r"""DeleteBranchRule deletes a branch rule. + r"""Deletes an issue comment. .. code-block:: python @@ -2822,17 +7573,17 @@ def delete_branch_rule( # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import securesourcemanager_v1 - def sample_delete_branch_rule(): + def sample_delete_issue_comment(): # Create a client client = securesourcemanager_v1.SecureSourceManagerClient() # Initialize request argument(s) - request = securesourcemanager_v1.DeleteBranchRuleRequest( + request = securesourcemanager_v1.DeleteIssueCommentRequest( name="name_value", ) # Make the request - operation = client.delete_branch_rule(request=request) + operation = client.delete_issue_comment(request=request) print("Waiting for operation to complete...") @@ -2842,10 +7593,13 @@ def sample_delete_branch_rule(): print(response) Args: - request (Union[google.cloud.securesourcemanager_v1.types.DeleteBranchRuleRequest, dict]): - The request object. DeleteBranchRuleRequest is the - request to delete a branch rule. + request (Union[google.cloud.securesourcemanager_v1.types.DeleteIssueCommentRequest, dict]): + The request object. The request to delete an issue + comment. name (str): + Required. Name of the issue comment to delete. The + format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}/issueComments/{comment_id}``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -2889,8 +7643,8 @@ def sample_delete_branch_rule(): # - Use the request object if provided (there's no risk of modifying the input as # there are no flattened fields), or create one. - if not isinstance(request, secure_source_manager.DeleteBranchRuleRequest): - request = secure_source_manager.DeleteBranchRuleRequest(request) + if not isinstance(request, secure_source_manager.DeleteIssueCommentRequest): + request = secure_source_manager.DeleteIssueCommentRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if name is not None: @@ -2898,7 +7652,7 @@ def sample_delete_branch_rule(): # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_branch_rule] + rpc = self._transport._wrapped_methods[self._transport.delete_issue_comment] # Certain fields should be provided within the metadata header; # add these here. diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/pagers.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/pagers.py index eec9ade6d467..8c800591e62c 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/pagers.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/pagers.py @@ -357,6 +357,162 @@ def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) +class ListHooksPager: + """A pager for iterating through ``list_hooks`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.ListHooksResponse` object, and + provides an ``__iter__`` method to iterate through its + ``hooks`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListHooks`` requests and continue to iterate + through the ``hooks`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.ListHooksResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., secure_source_manager.ListHooksResponse], + request: secure_source_manager.ListHooksRequest, + response: secure_source_manager.ListHooksResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.ListHooksRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.ListHooksResponse): + The initial response object. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.ListHooksRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[secure_source_manager.ListHooksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[secure_source_manager.Hook]: + for page in self.pages: + yield from page.hooks + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListHooksAsyncPager: + """A pager for iterating through ``list_hooks`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.ListHooksResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``hooks`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListHooks`` requests and continue to iterate + through the ``hooks`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.ListHooksResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[secure_source_manager.ListHooksResponse]], + request: secure_source_manager.ListHooksRequest, + response: secure_source_manager.ListHooksResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.ListHooksRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.ListHooksResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.ListHooksRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[secure_source_manager.ListHooksResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[secure_source_manager.Hook]: + async def async_generator(): + async for page in self.pages: + for response in page.hooks: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + class ListBranchRulesPager: """A pager for iterating through ``list_branch_rules`` requests. @@ -513,3 +669,955 @@ async def async_generator(): def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListPullRequestsPager: + """A pager for iterating through ``list_pull_requests`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.ListPullRequestsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``pull_requests`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListPullRequests`` requests and continue to iterate + through the ``pull_requests`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.ListPullRequestsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., secure_source_manager.ListPullRequestsResponse], + request: secure_source_manager.ListPullRequestsRequest, + response: secure_source_manager.ListPullRequestsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.ListPullRequestsRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.ListPullRequestsResponse): + The initial response object. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.ListPullRequestsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[secure_source_manager.ListPullRequestsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[secure_source_manager.PullRequest]: + for page in self.pages: + yield from page.pull_requests + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListPullRequestsAsyncPager: + """A pager for iterating through ``list_pull_requests`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.ListPullRequestsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``pull_requests`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListPullRequests`` requests and continue to iterate + through the ``pull_requests`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.ListPullRequestsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[secure_source_manager.ListPullRequestsResponse] + ], + request: secure_source_manager.ListPullRequestsRequest, + response: secure_source_manager.ListPullRequestsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.ListPullRequestsRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.ListPullRequestsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.ListPullRequestsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterator[secure_source_manager.ListPullRequestsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[secure_source_manager.PullRequest]: + async def async_generator(): + async for page in self.pages: + for response in page.pull_requests: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListPullRequestFileDiffsPager: + """A pager for iterating through ``list_pull_request_file_diffs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.ListPullRequestFileDiffsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``file_diffs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListPullRequestFileDiffs`` requests and continue to iterate + through the ``file_diffs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.ListPullRequestFileDiffsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., secure_source_manager.ListPullRequestFileDiffsResponse], + request: secure_source_manager.ListPullRequestFileDiffsRequest, + response: secure_source_manager.ListPullRequestFileDiffsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.ListPullRequestFileDiffsRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.ListPullRequestFileDiffsResponse): + The initial response object. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.ListPullRequestFileDiffsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[secure_source_manager.ListPullRequestFileDiffsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[secure_source_manager.FileDiff]: + for page in self.pages: + yield from page.file_diffs + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListPullRequestFileDiffsAsyncPager: + """A pager for iterating through ``list_pull_request_file_diffs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.ListPullRequestFileDiffsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``file_diffs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListPullRequestFileDiffs`` requests and continue to iterate + through the ``file_diffs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.ListPullRequestFileDiffsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[secure_source_manager.ListPullRequestFileDiffsResponse] + ], + request: secure_source_manager.ListPullRequestFileDiffsRequest, + response: secure_source_manager.ListPullRequestFileDiffsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.ListPullRequestFileDiffsRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.ListPullRequestFileDiffsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.ListPullRequestFileDiffsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterator[secure_source_manager.ListPullRequestFileDiffsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[secure_source_manager.FileDiff]: + async def async_generator(): + async for page in self.pages: + for response in page.file_diffs: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class FetchTreePager: + """A pager for iterating through ``fetch_tree`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.FetchTreeResponse` object, and + provides an ``__iter__`` method to iterate through its + ``tree_entries`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``FetchTree`` requests and continue to iterate + through the ``tree_entries`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.FetchTreeResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., secure_source_manager.FetchTreeResponse], + request: secure_source_manager.FetchTreeRequest, + response: secure_source_manager.FetchTreeResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.FetchTreeRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.FetchTreeResponse): + The initial response object. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.FetchTreeRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[secure_source_manager.FetchTreeResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[secure_source_manager.TreeEntry]: + for page in self.pages: + yield from page.tree_entries + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class FetchTreeAsyncPager: + """A pager for iterating through ``fetch_tree`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.FetchTreeResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``tree_entries`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``FetchTree`` requests and continue to iterate + through the ``tree_entries`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.FetchTreeResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[secure_source_manager.FetchTreeResponse]], + request: secure_source_manager.FetchTreeRequest, + response: secure_source_manager.FetchTreeResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.FetchTreeRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.FetchTreeResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.FetchTreeRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[secure_source_manager.FetchTreeResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[secure_source_manager.TreeEntry]: + async def async_generator(): + async for page in self.pages: + for response in page.tree_entries: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListIssuesPager: + """A pager for iterating through ``list_issues`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.ListIssuesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``issues`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListIssues`` requests and continue to iterate + through the ``issues`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.ListIssuesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., secure_source_manager.ListIssuesResponse], + request: secure_source_manager.ListIssuesRequest, + response: secure_source_manager.ListIssuesResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.ListIssuesRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.ListIssuesResponse): + The initial response object. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.ListIssuesRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[secure_source_manager.ListIssuesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[secure_source_manager.Issue]: + for page in self.pages: + yield from page.issues + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListIssuesAsyncPager: + """A pager for iterating through ``list_issues`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.ListIssuesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``issues`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListIssues`` requests and continue to iterate + through the ``issues`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.ListIssuesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[secure_source_manager.ListIssuesResponse]], + request: secure_source_manager.ListIssuesRequest, + response: secure_source_manager.ListIssuesResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.ListIssuesRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.ListIssuesResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.ListIssuesRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[secure_source_manager.ListIssuesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[secure_source_manager.Issue]: + async def async_generator(): + async for page in self.pages: + for response in page.issues: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListPullRequestCommentsPager: + """A pager for iterating through ``list_pull_request_comments`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.ListPullRequestCommentsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``pull_request_comments`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListPullRequestComments`` requests and continue to iterate + through the ``pull_request_comments`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.ListPullRequestCommentsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., secure_source_manager.ListPullRequestCommentsResponse], + request: secure_source_manager.ListPullRequestCommentsRequest, + response: secure_source_manager.ListPullRequestCommentsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.ListPullRequestCommentsRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.ListPullRequestCommentsResponse): + The initial response object. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.ListPullRequestCommentsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[secure_source_manager.ListPullRequestCommentsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[secure_source_manager.PullRequestComment]: + for page in self.pages: + yield from page.pull_request_comments + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListPullRequestCommentsAsyncPager: + """A pager for iterating through ``list_pull_request_comments`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.ListPullRequestCommentsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``pull_request_comments`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListPullRequestComments`` requests and continue to iterate + through the ``pull_request_comments`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.ListPullRequestCommentsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[secure_source_manager.ListPullRequestCommentsResponse] + ], + request: secure_source_manager.ListPullRequestCommentsRequest, + response: secure_source_manager.ListPullRequestCommentsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.ListPullRequestCommentsRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.ListPullRequestCommentsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.ListPullRequestCommentsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterator[secure_source_manager.ListPullRequestCommentsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[secure_source_manager.PullRequestComment]: + async def async_generator(): + async for page in self.pages: + for response in page.pull_request_comments: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListIssueCommentsPager: + """A pager for iterating through ``list_issue_comments`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.ListIssueCommentsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``issue_comments`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListIssueComments`` requests and continue to iterate + through the ``issue_comments`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.ListIssueCommentsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., secure_source_manager.ListIssueCommentsResponse], + request: secure_source_manager.ListIssueCommentsRequest, + response: secure_source_manager.ListIssueCommentsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.ListIssueCommentsRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.ListIssueCommentsResponse): + The initial response object. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.ListIssueCommentsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[secure_source_manager.ListIssueCommentsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[secure_source_manager.IssueComment]: + for page in self.pages: + yield from page.issue_comments + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListIssueCommentsAsyncPager: + """A pager for iterating through ``list_issue_comments`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securesourcemanager_v1.types.ListIssueCommentsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``issue_comments`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListIssueComments`` requests and continue to iterate + through the ``issue_comments`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securesourcemanager_v1.types.ListIssueCommentsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[secure_source_manager.ListIssueCommentsResponse] + ], + request: secure_source_manager.ListIssueCommentsRequest, + response: secure_source_manager.ListIssueCommentsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.securesourcemanager_v1.types.ListIssueCommentsRequest): + The initial request object. + response (google.cloud.securesourcemanager_v1.types.ListIssueCommentsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = secure_source_manager.ListIssueCommentsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterator[secure_source_manager.ListIssueCommentsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __aiter__(self) -> AsyncIterator[secure_source_manager.IssueComment]: + async def async_generator(): + async for page in self.pages: + for response in page.issue_comments: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/base.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/base.py index c3ade2740aee..860468e58f89 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/base.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/base.py @@ -207,11 +207,41 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.update_repository: gapic_v1.method.wrap_method( + self.update_repository, + default_timeout=None, + client_info=client_info, + ), self.delete_repository: gapic_v1.method.wrap_method( self.delete_repository, default_timeout=None, client_info=client_info, ), + self.list_hooks: gapic_v1.method.wrap_method( + self.list_hooks, + default_timeout=None, + client_info=client_info, + ), + self.get_hook: gapic_v1.method.wrap_method( + self.get_hook, + default_timeout=None, + client_info=client_info, + ), + self.create_hook: gapic_v1.method.wrap_method( + self.create_hook, + default_timeout=None, + client_info=client_info, + ), + self.update_hook: gapic_v1.method.wrap_method( + self.update_hook, + default_timeout=None, + client_info=client_info, + ), + self.delete_hook: gapic_v1.method.wrap_method( + self.delete_hook, + default_timeout=None, + client_info=client_info, + ), self.get_iam_policy_repo: gapic_v1.method.wrap_method( self.get_iam_policy_repo, default_retry=retries.Retry( @@ -261,6 +291,156 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.create_pull_request: gapic_v1.method.wrap_method( + self.create_pull_request, + default_timeout=None, + client_info=client_info, + ), + self.get_pull_request: gapic_v1.method.wrap_method( + self.get_pull_request, + default_timeout=None, + client_info=client_info, + ), + self.list_pull_requests: gapic_v1.method.wrap_method( + self.list_pull_requests, + default_timeout=None, + client_info=client_info, + ), + self.update_pull_request: gapic_v1.method.wrap_method( + self.update_pull_request, + default_timeout=None, + client_info=client_info, + ), + self.merge_pull_request: gapic_v1.method.wrap_method( + self.merge_pull_request, + default_timeout=None, + client_info=client_info, + ), + self.open_pull_request: gapic_v1.method.wrap_method( + self.open_pull_request, + default_timeout=None, + client_info=client_info, + ), + self.close_pull_request: gapic_v1.method.wrap_method( + self.close_pull_request, + default_timeout=None, + client_info=client_info, + ), + self.list_pull_request_file_diffs: gapic_v1.method.wrap_method( + self.list_pull_request_file_diffs, + default_timeout=None, + client_info=client_info, + ), + self.fetch_tree: gapic_v1.method.wrap_method( + self.fetch_tree, + default_timeout=None, + client_info=client_info, + ), + self.fetch_blob: gapic_v1.method.wrap_method( + self.fetch_blob, + default_timeout=None, + client_info=client_info, + ), + self.create_issue: gapic_v1.method.wrap_method( + self.create_issue, + default_timeout=None, + client_info=client_info, + ), + self.get_issue: gapic_v1.method.wrap_method( + self.get_issue, + default_timeout=None, + client_info=client_info, + ), + self.list_issues: gapic_v1.method.wrap_method( + self.list_issues, + default_timeout=None, + client_info=client_info, + ), + self.update_issue: gapic_v1.method.wrap_method( + self.update_issue, + default_timeout=None, + client_info=client_info, + ), + self.delete_issue: gapic_v1.method.wrap_method( + self.delete_issue, + default_timeout=None, + client_info=client_info, + ), + self.open_issue: gapic_v1.method.wrap_method( + self.open_issue, + default_timeout=None, + client_info=client_info, + ), + self.close_issue: gapic_v1.method.wrap_method( + self.close_issue, + default_timeout=None, + client_info=client_info, + ), + self.get_pull_request_comment: gapic_v1.method.wrap_method( + self.get_pull_request_comment, + default_timeout=None, + client_info=client_info, + ), + self.list_pull_request_comments: gapic_v1.method.wrap_method( + self.list_pull_request_comments, + default_timeout=None, + client_info=client_info, + ), + self.create_pull_request_comment: gapic_v1.method.wrap_method( + self.create_pull_request_comment, + default_timeout=None, + client_info=client_info, + ), + self.update_pull_request_comment: gapic_v1.method.wrap_method( + self.update_pull_request_comment, + default_timeout=None, + client_info=client_info, + ), + self.delete_pull_request_comment: gapic_v1.method.wrap_method( + self.delete_pull_request_comment, + default_timeout=None, + client_info=client_info, + ), + self.batch_create_pull_request_comments: gapic_v1.method.wrap_method( + self.batch_create_pull_request_comments, + default_timeout=None, + client_info=client_info, + ), + self.resolve_pull_request_comments: gapic_v1.method.wrap_method( + self.resolve_pull_request_comments, + default_timeout=None, + client_info=client_info, + ), + self.unresolve_pull_request_comments: gapic_v1.method.wrap_method( + self.unresolve_pull_request_comments, + default_timeout=None, + client_info=client_info, + ), + self.create_issue_comment: gapic_v1.method.wrap_method( + self.create_issue_comment, + default_timeout=None, + client_info=client_info, + ), + self.get_issue_comment: gapic_v1.method.wrap_method( + self.get_issue_comment, + default_timeout=None, + client_info=client_info, + ), + self.list_issue_comments: gapic_v1.method.wrap_method( + self.list_issue_comments, + default_timeout=None, + client_info=client_info, + ), + self.update_issue_comment: gapic_v1.method.wrap_method( + self.update_issue_comment, + default_timeout=None, + client_info=client_info, + ), + self.delete_issue_comment: gapic_v1.method.wrap_method( + self.delete_issue_comment, + default_timeout=None, + client_info=client_info, + ), self.get_location: gapic_v1.method.wrap_method( self.get_location, default_timeout=None, @@ -396,6 +576,15 @@ def create_repository( ]: raise NotImplementedError() + @property + def update_repository( + self, + ) -> Callable[ + [secure_source_manager.UpdateRepositoryRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def delete_repository( self, @@ -405,6 +594,54 @@ def delete_repository( ]: raise NotImplementedError() + @property + def list_hooks( + self, + ) -> Callable[ + [secure_source_manager.ListHooksRequest], + Union[ + secure_source_manager.ListHooksResponse, + Awaitable[secure_source_manager.ListHooksResponse], + ], + ]: + raise NotImplementedError() + + @property + def get_hook( + self, + ) -> Callable[ + [secure_source_manager.GetHookRequest], + Union[secure_source_manager.Hook, Awaitable[secure_source_manager.Hook]], + ]: + raise NotImplementedError() + + @property + def create_hook( + self, + ) -> Callable[ + [secure_source_manager.CreateHookRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def update_hook( + self, + ) -> Callable[ + [secure_source_manager.UpdateHookRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def delete_hook( + self, + ) -> Callable[ + [secure_source_manager.DeleteHookRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def get_iam_policy_repo( self, @@ -486,6 +723,306 @@ def delete_branch_rule( ]: raise NotImplementedError() + @property + def create_pull_request( + self, + ) -> Callable[ + [secure_source_manager.CreatePullRequestRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def get_pull_request( + self, + ) -> Callable[ + [secure_source_manager.GetPullRequestRequest], + Union[ + secure_source_manager.PullRequest, + Awaitable[secure_source_manager.PullRequest], + ], + ]: + raise NotImplementedError() + + @property + def list_pull_requests( + self, + ) -> Callable[ + [secure_source_manager.ListPullRequestsRequest], + Union[ + secure_source_manager.ListPullRequestsResponse, + Awaitable[secure_source_manager.ListPullRequestsResponse], + ], + ]: + raise NotImplementedError() + + @property + def update_pull_request( + self, + ) -> Callable[ + [secure_source_manager.UpdatePullRequestRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def merge_pull_request( + self, + ) -> Callable[ + [secure_source_manager.MergePullRequestRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def open_pull_request( + self, + ) -> Callable[ + [secure_source_manager.OpenPullRequestRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def close_pull_request( + self, + ) -> Callable[ + [secure_source_manager.ClosePullRequestRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def list_pull_request_file_diffs( + self, + ) -> Callable[ + [secure_source_manager.ListPullRequestFileDiffsRequest], + Union[ + secure_source_manager.ListPullRequestFileDiffsResponse, + Awaitable[secure_source_manager.ListPullRequestFileDiffsResponse], + ], + ]: + raise NotImplementedError() + + @property + def fetch_tree( + self, + ) -> Callable[ + [secure_source_manager.FetchTreeRequest], + Union[ + secure_source_manager.FetchTreeResponse, + Awaitable[secure_source_manager.FetchTreeResponse], + ], + ]: + raise NotImplementedError() + + @property + def fetch_blob( + self, + ) -> Callable[ + [secure_source_manager.FetchBlobRequest], + Union[ + secure_source_manager.FetchBlobResponse, + Awaitable[secure_source_manager.FetchBlobResponse], + ], + ]: + raise NotImplementedError() + + @property + def create_issue( + self, + ) -> Callable[ + [secure_source_manager.CreateIssueRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def get_issue( + self, + ) -> Callable[ + [secure_source_manager.GetIssueRequest], + Union[secure_source_manager.Issue, Awaitable[secure_source_manager.Issue]], + ]: + raise NotImplementedError() + + @property + def list_issues( + self, + ) -> Callable[ + [secure_source_manager.ListIssuesRequest], + Union[ + secure_source_manager.ListIssuesResponse, + Awaitable[secure_source_manager.ListIssuesResponse], + ], + ]: + raise NotImplementedError() + + @property + def update_issue( + self, + ) -> Callable[ + [secure_source_manager.UpdateIssueRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def delete_issue( + self, + ) -> Callable[ + [secure_source_manager.DeleteIssueRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def open_issue( + self, + ) -> Callable[ + [secure_source_manager.OpenIssueRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def close_issue( + self, + ) -> Callable[ + [secure_source_manager.CloseIssueRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def get_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.GetPullRequestCommentRequest], + Union[ + secure_source_manager.PullRequestComment, + Awaitable[secure_source_manager.PullRequestComment], + ], + ]: + raise NotImplementedError() + + @property + def list_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.ListPullRequestCommentsRequest], + Union[ + secure_source_manager.ListPullRequestCommentsResponse, + Awaitable[secure_source_manager.ListPullRequestCommentsResponse], + ], + ]: + raise NotImplementedError() + + @property + def create_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.CreatePullRequestCommentRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def update_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.UpdatePullRequestCommentRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def delete_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.DeletePullRequestCommentRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def batch_create_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.BatchCreatePullRequestCommentsRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def resolve_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.ResolvePullRequestCommentsRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def unresolve_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.UnresolvePullRequestCommentsRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def create_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.CreateIssueCommentRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def get_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.GetIssueCommentRequest], + Union[ + secure_source_manager.IssueComment, + Awaitable[secure_source_manager.IssueComment], + ], + ]: + raise NotImplementedError() + + @property + def list_issue_comments( + self, + ) -> Callable[ + [secure_source_manager.ListIssueCommentsRequest], + Union[ + secure_source_manager.ListIssueCommentsResponse, + Awaitable[secure_source_manager.ListIssueCommentsResponse], + ], + ]: + raise NotImplementedError() + + @property + def update_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.UpdateIssueCommentRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def delete_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.DeleteIssueCommentRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def list_operations( self, diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc.py index 9d4cd83610bf..5e702632a634 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc.py @@ -116,29 +116,8 @@ class SecureSourceManagerGrpcTransport(SecureSourceManagerTransport): Secure Source Manager API - Access Secure Source Manager instances, resources, and repositories. - - This API is split across two servers: the Control Plane and the Data - Plane. - - Data Plane endpoints are hosted directly by your Secure Source - Manager instance, so you must connect to your instance's API - hostname to access them. The API hostname looks like the following: - - :: - - https://[instance-id]-[project-number]-api.[location].sourcemanager.dev - - For example, - - :: - - https://my-instance-702770452863-api.us-central1.sourcemanager.dev - - Data Plane endpoints are denoted with **Host: Data Plane**. - - All other endpoints are found in the normal Cloud API location, - namely, ``securcesourcemanager.googleapis.com``. + Access Secure Source Manager instances, resources, and + repositories. This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation @@ -489,7 +468,9 @@ def list_repositories( Lists Repositories in a given project and location. - **Host: Data Plane** + The instance field is required in the query parameter + for requests using the + securesourcemanager.googleapis.com endpoint. Returns: Callable[[~.ListRepositoriesRequest], @@ -519,8 +500,6 @@ def get_repository( Gets metadata of a repository. - **Host: Data Plane** - Returns: Callable[[~.GetRepositoryRequest], ~.Repository]: @@ -547,9 +526,11 @@ def create_repository( ]: r"""Return a callable for the create repository method over gRPC. - Creates a new repository in a given project and location. - - **Host: Data Plane** + Creates a new repository in a given project and + location. + The Repository.Instance field is required in the request + body for requests using the + securesourcemanager.googleapis.com endpoint. Returns: Callable[[~.CreateRepositoryRequest], @@ -569,6 +550,34 @@ def create_repository( ) return self._stubs["create_repository"] + @property + def update_repository( + self, + ) -> Callable[ + [secure_source_manager.UpdateRepositoryRequest], operations_pb2.Operation + ]: + r"""Return a callable for the update repository method over gRPC. + + Updates the metadata of a repository. + + Returns: + Callable[[~.UpdateRepositoryRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_repository" not in self._stubs: + self._stubs["update_repository"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdateRepository", + request_serializer=secure_source_manager.UpdateRepositoryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_repository"] + @property def delete_repository( self, @@ -579,8 +588,6 @@ def delete_repository( Deletes a Repository. - **Host: Data Plane** - Returns: Callable[[~.DeleteRepositoryRequest], ~.Operation]: @@ -599,6 +606,139 @@ def delete_repository( ) return self._stubs["delete_repository"] + @property + def list_hooks( + self, + ) -> Callable[ + [secure_source_manager.ListHooksRequest], + secure_source_manager.ListHooksResponse, + ]: + r"""Return a callable for the list hooks method over gRPC. + + Lists hooks in a given repository. + + Returns: + Callable[[~.ListHooksRequest], + ~.ListHooksResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_hooks" not in self._stubs: + self._stubs["list_hooks"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListHooks", + request_serializer=secure_source_manager.ListHooksRequest.serialize, + response_deserializer=secure_source_manager.ListHooksResponse.deserialize, + ) + return self._stubs["list_hooks"] + + @property + def get_hook( + self, + ) -> Callable[[secure_source_manager.GetHookRequest], secure_source_manager.Hook]: + r"""Return a callable for the get hook method over gRPC. + + Gets metadata of a hook. + + Returns: + Callable[[~.GetHookRequest], + ~.Hook]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_hook" not in self._stubs: + self._stubs["get_hook"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetHook", + request_serializer=secure_source_manager.GetHookRequest.serialize, + response_deserializer=secure_source_manager.Hook.deserialize, + ) + return self._stubs["get_hook"] + + @property + def create_hook( + self, + ) -> Callable[[secure_source_manager.CreateHookRequest], operations_pb2.Operation]: + r"""Return a callable for the create hook method over gRPC. + + Creates a new hook in a given repository. + + Returns: + Callable[[~.CreateHookRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_hook" not in self._stubs: + self._stubs["create_hook"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateHook", + request_serializer=secure_source_manager.CreateHookRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_hook"] + + @property + def update_hook( + self, + ) -> Callable[[secure_source_manager.UpdateHookRequest], operations_pb2.Operation]: + r"""Return a callable for the update hook method over gRPC. + + Updates the metadata of a hook. + + Returns: + Callable[[~.UpdateHookRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_hook" not in self._stubs: + self._stubs["update_hook"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdateHook", + request_serializer=secure_source_manager.UpdateHookRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_hook"] + + @property + def delete_hook( + self, + ) -> Callable[[secure_source_manager.DeleteHookRequest], operations_pb2.Operation]: + r"""Return a callable for the delete hook method over gRPC. + + Deletes a Hook. + + Returns: + Callable[[~.DeleteHookRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_hook" not in self._stubs: + self._stubs["delete_hook"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteHook", + request_serializer=secure_source_manager.DeleteHookRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_hook"] + @property def get_iam_policy_repo( self, @@ -824,6 +964,867 @@ def delete_branch_rule( ) return self._stubs["delete_branch_rule"] + @property + def create_pull_request( + self, + ) -> Callable[ + [secure_source_manager.CreatePullRequestRequest], operations_pb2.Operation + ]: + r"""Return a callable for the create pull request method over gRPC. + + Creates a pull request. + + Returns: + Callable[[~.CreatePullRequestRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_pull_request" not in self._stubs: + self._stubs["create_pull_request"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreatePullRequest", + request_serializer=secure_source_manager.CreatePullRequestRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_pull_request"] + + @property + def get_pull_request( + self, + ) -> Callable[ + [secure_source_manager.GetPullRequestRequest], secure_source_manager.PullRequest + ]: + r"""Return a callable for the get pull request method over gRPC. + + Gets a pull request. + + Returns: + Callable[[~.GetPullRequestRequest], + ~.PullRequest]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_pull_request" not in self._stubs: + self._stubs["get_pull_request"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetPullRequest", + request_serializer=secure_source_manager.GetPullRequestRequest.serialize, + response_deserializer=secure_source_manager.PullRequest.deserialize, + ) + return self._stubs["get_pull_request"] + + @property + def list_pull_requests( + self, + ) -> Callable[ + [secure_source_manager.ListPullRequestsRequest], + secure_source_manager.ListPullRequestsResponse, + ]: + r"""Return a callable for the list pull requests method over gRPC. + + Lists pull requests in a repository. + + Returns: + Callable[[~.ListPullRequestsRequest], + ~.ListPullRequestsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_pull_requests" not in self._stubs: + self._stubs["list_pull_requests"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListPullRequests", + request_serializer=secure_source_manager.ListPullRequestsRequest.serialize, + response_deserializer=secure_source_manager.ListPullRequestsResponse.deserialize, + ) + return self._stubs["list_pull_requests"] + + @property + def update_pull_request( + self, + ) -> Callable[ + [secure_source_manager.UpdatePullRequestRequest], operations_pb2.Operation + ]: + r"""Return a callable for the update pull request method over gRPC. + + Updates a pull request. + + Returns: + Callable[[~.UpdatePullRequestRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_pull_request" not in self._stubs: + self._stubs["update_pull_request"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdatePullRequest", + request_serializer=secure_source_manager.UpdatePullRequestRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_pull_request"] + + @property + def merge_pull_request( + self, + ) -> Callable[ + [secure_source_manager.MergePullRequestRequest], operations_pb2.Operation + ]: + r"""Return a callable for the merge pull request method over gRPC. + + Merges a pull request. + + Returns: + Callable[[~.MergePullRequestRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "merge_pull_request" not in self._stubs: + self._stubs["merge_pull_request"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/MergePullRequest", + request_serializer=secure_source_manager.MergePullRequestRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["merge_pull_request"] + + @property + def open_pull_request( + self, + ) -> Callable[ + [secure_source_manager.OpenPullRequestRequest], operations_pb2.Operation + ]: + r"""Return a callable for the open pull request method over gRPC. + + Opens a pull request. + + Returns: + Callable[[~.OpenPullRequestRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "open_pull_request" not in self._stubs: + self._stubs["open_pull_request"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/OpenPullRequest", + request_serializer=secure_source_manager.OpenPullRequestRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["open_pull_request"] + + @property + def close_pull_request( + self, + ) -> Callable[ + [secure_source_manager.ClosePullRequestRequest], operations_pb2.Operation + ]: + r"""Return a callable for the close pull request method over gRPC. + + Closes a pull request without merging. + + Returns: + Callable[[~.ClosePullRequestRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "close_pull_request" not in self._stubs: + self._stubs["close_pull_request"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ClosePullRequest", + request_serializer=secure_source_manager.ClosePullRequestRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["close_pull_request"] + + @property + def list_pull_request_file_diffs( + self, + ) -> Callable[ + [secure_source_manager.ListPullRequestFileDiffsRequest], + secure_source_manager.ListPullRequestFileDiffsResponse, + ]: + r"""Return a callable for the list pull request file diffs method over gRPC. + + Lists a pull request's file diffs. + + Returns: + Callable[[~.ListPullRequestFileDiffsRequest], + ~.ListPullRequestFileDiffsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_pull_request_file_diffs" not in self._stubs: + self._stubs[ + "list_pull_request_file_diffs" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListPullRequestFileDiffs", + request_serializer=secure_source_manager.ListPullRequestFileDiffsRequest.serialize, + response_deserializer=secure_source_manager.ListPullRequestFileDiffsResponse.deserialize, + ) + return self._stubs["list_pull_request_file_diffs"] + + @property + def fetch_tree( + self, + ) -> Callable[ + [secure_source_manager.FetchTreeRequest], + secure_source_manager.FetchTreeResponse, + ]: + r"""Return a callable for the fetch tree method over gRPC. + + Fetches a tree from a repository. + + Returns: + Callable[[~.FetchTreeRequest], + ~.FetchTreeResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "fetch_tree" not in self._stubs: + self._stubs["fetch_tree"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/FetchTree", + request_serializer=secure_source_manager.FetchTreeRequest.serialize, + response_deserializer=secure_source_manager.FetchTreeResponse.deserialize, + ) + return self._stubs["fetch_tree"] + + @property + def fetch_blob( + self, + ) -> Callable[ + [secure_source_manager.FetchBlobRequest], + secure_source_manager.FetchBlobResponse, + ]: + r"""Return a callable for the fetch blob method over gRPC. + + Fetches a blob from a repository. + + Returns: + Callable[[~.FetchBlobRequest], + ~.FetchBlobResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "fetch_blob" not in self._stubs: + self._stubs["fetch_blob"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/FetchBlob", + request_serializer=secure_source_manager.FetchBlobRequest.serialize, + response_deserializer=secure_source_manager.FetchBlobResponse.deserialize, + ) + return self._stubs["fetch_blob"] + + @property + def create_issue( + self, + ) -> Callable[[secure_source_manager.CreateIssueRequest], operations_pb2.Operation]: + r"""Return a callable for the create issue method over gRPC. + + Creates an issue. + + Returns: + Callable[[~.CreateIssueRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_issue" not in self._stubs: + self._stubs["create_issue"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateIssue", + request_serializer=secure_source_manager.CreateIssueRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_issue"] + + @property + def get_issue( + self, + ) -> Callable[[secure_source_manager.GetIssueRequest], secure_source_manager.Issue]: + r"""Return a callable for the get issue method over gRPC. + + Gets an issue. + + Returns: + Callable[[~.GetIssueRequest], + ~.Issue]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_issue" not in self._stubs: + self._stubs["get_issue"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetIssue", + request_serializer=secure_source_manager.GetIssueRequest.serialize, + response_deserializer=secure_source_manager.Issue.deserialize, + ) + return self._stubs["get_issue"] + + @property + def list_issues( + self, + ) -> Callable[ + [secure_source_manager.ListIssuesRequest], + secure_source_manager.ListIssuesResponse, + ]: + r"""Return a callable for the list issues method over gRPC. + + Lists issues in a repository. + + Returns: + Callable[[~.ListIssuesRequest], + ~.ListIssuesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_issues" not in self._stubs: + self._stubs["list_issues"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListIssues", + request_serializer=secure_source_manager.ListIssuesRequest.serialize, + response_deserializer=secure_source_manager.ListIssuesResponse.deserialize, + ) + return self._stubs["list_issues"] + + @property + def update_issue( + self, + ) -> Callable[[secure_source_manager.UpdateIssueRequest], operations_pb2.Operation]: + r"""Return a callable for the update issue method over gRPC. + + Updates a issue. + + Returns: + Callable[[~.UpdateIssueRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_issue" not in self._stubs: + self._stubs["update_issue"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdateIssue", + request_serializer=secure_source_manager.UpdateIssueRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_issue"] + + @property + def delete_issue( + self, + ) -> Callable[[secure_source_manager.DeleteIssueRequest], operations_pb2.Operation]: + r"""Return a callable for the delete issue method over gRPC. + + Deletes an issue. + + Returns: + Callable[[~.DeleteIssueRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_issue" not in self._stubs: + self._stubs["delete_issue"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteIssue", + request_serializer=secure_source_manager.DeleteIssueRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_issue"] + + @property + def open_issue( + self, + ) -> Callable[[secure_source_manager.OpenIssueRequest], operations_pb2.Operation]: + r"""Return a callable for the open issue method over gRPC. + + Opens an issue. + + Returns: + Callable[[~.OpenIssueRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "open_issue" not in self._stubs: + self._stubs["open_issue"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/OpenIssue", + request_serializer=secure_source_manager.OpenIssueRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["open_issue"] + + @property + def close_issue( + self, + ) -> Callable[[secure_source_manager.CloseIssueRequest], operations_pb2.Operation]: + r"""Return a callable for the close issue method over gRPC. + + Closes an issue. + + Returns: + Callable[[~.CloseIssueRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "close_issue" not in self._stubs: + self._stubs["close_issue"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/CloseIssue", + request_serializer=secure_source_manager.CloseIssueRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["close_issue"] + + @property + def get_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.GetPullRequestCommentRequest], + secure_source_manager.PullRequestComment, + ]: + r"""Return a callable for the get pull request comment method over gRPC. + + Gets a pull request comment. + + Returns: + Callable[[~.GetPullRequestCommentRequest], + ~.PullRequestComment]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_pull_request_comment" not in self._stubs: + self._stubs["get_pull_request_comment"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetPullRequestComment", + request_serializer=secure_source_manager.GetPullRequestCommentRequest.serialize, + response_deserializer=secure_source_manager.PullRequestComment.deserialize, + ) + return self._stubs["get_pull_request_comment"] + + @property + def list_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.ListPullRequestCommentsRequest], + secure_source_manager.ListPullRequestCommentsResponse, + ]: + r"""Return a callable for the list pull request comments method over gRPC. + + Lists pull request comments. + + Returns: + Callable[[~.ListPullRequestCommentsRequest], + ~.ListPullRequestCommentsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_pull_request_comments" not in self._stubs: + self._stubs[ + "list_pull_request_comments" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListPullRequestComments", + request_serializer=secure_source_manager.ListPullRequestCommentsRequest.serialize, + response_deserializer=secure_source_manager.ListPullRequestCommentsResponse.deserialize, + ) + return self._stubs["list_pull_request_comments"] + + @property + def create_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.CreatePullRequestCommentRequest], + operations_pb2.Operation, + ]: + r"""Return a callable for the create pull request comment method over gRPC. + + Creates a pull request comment. + + Returns: + Callable[[~.CreatePullRequestCommentRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_pull_request_comment" not in self._stubs: + self._stubs[ + "create_pull_request_comment" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreatePullRequestComment", + request_serializer=secure_source_manager.CreatePullRequestCommentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_pull_request_comment"] + + @property + def update_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.UpdatePullRequestCommentRequest], + operations_pb2.Operation, + ]: + r"""Return a callable for the update pull request comment method over gRPC. + + Updates a pull request comment. + + Returns: + Callable[[~.UpdatePullRequestCommentRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_pull_request_comment" not in self._stubs: + self._stubs[ + "update_pull_request_comment" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdatePullRequestComment", + request_serializer=secure_source_manager.UpdatePullRequestCommentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_pull_request_comment"] + + @property + def delete_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.DeletePullRequestCommentRequest], + operations_pb2.Operation, + ]: + r"""Return a callable for the delete pull request comment method over gRPC. + + Deletes a pull request comment. + + Returns: + Callable[[~.DeletePullRequestCommentRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_pull_request_comment" not in self._stubs: + self._stubs[ + "delete_pull_request_comment" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeletePullRequestComment", + request_serializer=secure_source_manager.DeletePullRequestCommentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_pull_request_comment"] + + @property + def batch_create_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.BatchCreatePullRequestCommentsRequest], + operations_pb2.Operation, + ]: + r"""Return a callable for the batch create pull request + comments method over gRPC. + + Batch creates pull request comments. + + Returns: + Callable[[~.BatchCreatePullRequestCommentsRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "batch_create_pull_request_comments" not in self._stubs: + self._stubs[ + "batch_create_pull_request_comments" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/BatchCreatePullRequestComments", + request_serializer=secure_source_manager.BatchCreatePullRequestCommentsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["batch_create_pull_request_comments"] + + @property + def resolve_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.ResolvePullRequestCommentsRequest], + operations_pb2.Operation, + ]: + r"""Return a callable for the resolve pull request comments method over gRPC. + + Resolves pull request comments. + + Returns: + Callable[[~.ResolvePullRequestCommentsRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "resolve_pull_request_comments" not in self._stubs: + self._stubs[ + "resolve_pull_request_comments" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ResolvePullRequestComments", + request_serializer=secure_source_manager.ResolvePullRequestCommentsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["resolve_pull_request_comments"] + + @property + def unresolve_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.UnresolvePullRequestCommentsRequest], + operations_pb2.Operation, + ]: + r"""Return a callable for the unresolve pull request + comments method over gRPC. + + Unresolves pull request comment. + + Returns: + Callable[[~.UnresolvePullRequestCommentsRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "unresolve_pull_request_comments" not in self._stubs: + self._stubs[ + "unresolve_pull_request_comments" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UnresolvePullRequestComments", + request_serializer=secure_source_manager.UnresolvePullRequestCommentsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["unresolve_pull_request_comments"] + + @property + def create_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.CreateIssueCommentRequest], operations_pb2.Operation + ]: + r"""Return a callable for the create issue comment method over gRPC. + + Creates an issue comment. + + Returns: + Callable[[~.CreateIssueCommentRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_issue_comment" not in self._stubs: + self._stubs["create_issue_comment"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateIssueComment", + request_serializer=secure_source_manager.CreateIssueCommentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_issue_comment"] + + @property + def get_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.GetIssueCommentRequest], + secure_source_manager.IssueComment, + ]: + r"""Return a callable for the get issue comment method over gRPC. + + Gets an issue comment. + + Returns: + Callable[[~.GetIssueCommentRequest], + ~.IssueComment]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_issue_comment" not in self._stubs: + self._stubs["get_issue_comment"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetIssueComment", + request_serializer=secure_source_manager.GetIssueCommentRequest.serialize, + response_deserializer=secure_source_manager.IssueComment.deserialize, + ) + return self._stubs["get_issue_comment"] + + @property + def list_issue_comments( + self, + ) -> Callable[ + [secure_source_manager.ListIssueCommentsRequest], + secure_source_manager.ListIssueCommentsResponse, + ]: + r"""Return a callable for the list issue comments method over gRPC. + + Lists comments in an issue. + + Returns: + Callable[[~.ListIssueCommentsRequest], + ~.ListIssueCommentsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_issue_comments" not in self._stubs: + self._stubs["list_issue_comments"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListIssueComments", + request_serializer=secure_source_manager.ListIssueCommentsRequest.serialize, + response_deserializer=secure_source_manager.ListIssueCommentsResponse.deserialize, + ) + return self._stubs["list_issue_comments"] + + @property + def update_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.UpdateIssueCommentRequest], operations_pb2.Operation + ]: + r"""Return a callable for the update issue comment method over gRPC. + + Updates an issue comment. + + Returns: + Callable[[~.UpdateIssueCommentRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_issue_comment" not in self._stubs: + self._stubs["update_issue_comment"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdateIssueComment", + request_serializer=secure_source_manager.UpdateIssueCommentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_issue_comment"] + + @property + def delete_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.DeleteIssueCommentRequest], operations_pb2.Operation + ]: + r"""Return a callable for the delete issue comment method over gRPC. + + Deletes an issue comment. + + Returns: + Callable[[~.DeleteIssueCommentRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_issue_comment" not in self._stubs: + self._stubs["delete_issue_comment"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteIssueComment", + request_serializer=secure_source_manager.DeleteIssueCommentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_issue_comment"] + def close(self): self._logged_channel.close() diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc_asyncio.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc_asyncio.py index 31098a730f2b..c3def8659d78 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc_asyncio.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/grpc_asyncio.py @@ -122,29 +122,8 @@ class SecureSourceManagerGrpcAsyncIOTransport(SecureSourceManagerTransport): Secure Source Manager API - Access Secure Source Manager instances, resources, and repositories. - - This API is split across two servers: the Control Plane and the Data - Plane. - - Data Plane endpoints are hosted directly by your Secure Source - Manager instance, so you must connect to your instance's API - hostname to access them. The API hostname looks like the following: - - :: - - https://[instance-id]-[project-number]-api.[location].sourcemanager.dev - - For example, - - :: - - https://my-instance-702770452863-api.us-central1.sourcemanager.dev - - Data Plane endpoints are denoted with **Host: Data Plane**. - - All other endpoints are found in the normal Cloud API location, - namely, ``securcesourcemanager.googleapis.com``. + Access Secure Source Manager instances, resources, and + repositories. This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation @@ -500,7 +479,9 @@ def list_repositories( Lists Repositories in a given project and location. - **Host: Data Plane** + The instance field is required in the query parameter + for requests using the + securesourcemanager.googleapis.com endpoint. Returns: Callable[[~.ListRepositoriesRequest], @@ -531,8 +512,6 @@ def get_repository( Gets metadata of a repository. - **Host: Data Plane** - Returns: Callable[[~.GetRepositoryRequest], Awaitable[~.Repository]]: @@ -560,9 +539,11 @@ def create_repository( ]: r"""Return a callable for the create repository method over gRPC. - Creates a new repository in a given project and location. - - **Host: Data Plane** + Creates a new repository in a given project and + location. + The Repository.Instance field is required in the request + body for requests using the + securesourcemanager.googleapis.com endpoint. Returns: Callable[[~.CreateRepositoryRequest], @@ -582,6 +563,35 @@ def create_repository( ) return self._stubs["create_repository"] + @property + def update_repository( + self, + ) -> Callable[ + [secure_source_manager.UpdateRepositoryRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the update repository method over gRPC. + + Updates the metadata of a repository. + + Returns: + Callable[[~.UpdateRepositoryRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_repository" not in self._stubs: + self._stubs["update_repository"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdateRepository", + request_serializer=secure_source_manager.UpdateRepositoryRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_repository"] + @property def delete_repository( self, @@ -593,8 +603,6 @@ def delete_repository( Deletes a Repository. - **Host: Data Plane** - Returns: Callable[[~.DeleteRepositoryRequest], Awaitable[~.Operation]]: @@ -613,6 +621,147 @@ def delete_repository( ) return self._stubs["delete_repository"] + @property + def list_hooks( + self, + ) -> Callable[ + [secure_source_manager.ListHooksRequest], + Awaitable[secure_source_manager.ListHooksResponse], + ]: + r"""Return a callable for the list hooks method over gRPC. + + Lists hooks in a given repository. + + Returns: + Callable[[~.ListHooksRequest], + Awaitable[~.ListHooksResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_hooks" not in self._stubs: + self._stubs["list_hooks"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListHooks", + request_serializer=secure_source_manager.ListHooksRequest.serialize, + response_deserializer=secure_source_manager.ListHooksResponse.deserialize, + ) + return self._stubs["list_hooks"] + + @property + def get_hook( + self, + ) -> Callable[ + [secure_source_manager.GetHookRequest], Awaitable[secure_source_manager.Hook] + ]: + r"""Return a callable for the get hook method over gRPC. + + Gets metadata of a hook. + + Returns: + Callable[[~.GetHookRequest], + Awaitable[~.Hook]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_hook" not in self._stubs: + self._stubs["get_hook"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetHook", + request_serializer=secure_source_manager.GetHookRequest.serialize, + response_deserializer=secure_source_manager.Hook.deserialize, + ) + return self._stubs["get_hook"] + + @property + def create_hook( + self, + ) -> Callable[ + [secure_source_manager.CreateHookRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the create hook method over gRPC. + + Creates a new hook in a given repository. + + Returns: + Callable[[~.CreateHookRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_hook" not in self._stubs: + self._stubs["create_hook"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateHook", + request_serializer=secure_source_manager.CreateHookRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_hook"] + + @property + def update_hook( + self, + ) -> Callable[ + [secure_source_manager.UpdateHookRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the update hook method over gRPC. + + Updates the metadata of a hook. + + Returns: + Callable[[~.UpdateHookRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_hook" not in self._stubs: + self._stubs["update_hook"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdateHook", + request_serializer=secure_source_manager.UpdateHookRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_hook"] + + @property + def delete_hook( + self, + ) -> Callable[ + [secure_source_manager.DeleteHookRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the delete hook method over gRPC. + + Deletes a Hook. + + Returns: + Callable[[~.DeleteHookRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_hook" not in self._stubs: + self._stubs["delete_hook"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteHook", + request_serializer=secure_source_manager.DeleteHookRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_hook"] + @property def get_iam_policy_repo( self, @@ -842,131 +991,1193 @@ def delete_branch_rule( ) return self._stubs["delete_branch_rule"] - def _prep_wrapped_messages(self, client_info): - """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" - self._wrapped_methods = { - self.list_instances: self._wrap_method( - self.list_instances, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_instance: self._wrap_method( - self.get_instance, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_instance: self._wrap_method( - self.create_instance, - default_timeout=None, - client_info=client_info, - ), - self.delete_instance: self._wrap_method( - self.delete_instance, - default_timeout=None, - client_info=client_info, - ), - self.list_repositories: self._wrap_method( - self.list_repositories, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_repository: self._wrap_method( - self.get_repository, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_repository: self._wrap_method( - self.create_repository, - default_timeout=None, - client_info=client_info, - ), - self.delete_repository: self._wrap_method( - self.delete_repository, - default_timeout=None, - client_info=client_info, - ), - self.get_iam_policy_repo: self._wrap_method( - self.get_iam_policy_repo, - default_retry=retries.AsyncRetry( - initial=1.0, - maximum=10.0, - multiplier=1.3, - predicate=retries.if_exception_type( - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.set_iam_policy_repo: self._wrap_method( - self.set_iam_policy_repo, - default_timeout=None, - client_info=client_info, - ), - self.test_iam_permissions_repo: self._wrap_method( - self.test_iam_permissions_repo, - default_timeout=None, - client_info=client_info, - ), - self.create_branch_rule: self._wrap_method( - self.create_branch_rule, - default_timeout=None, - client_info=client_info, - ), - self.list_branch_rules: self._wrap_method( - self.list_branch_rules, - default_timeout=None, - client_info=client_info, - ), - self.get_branch_rule: self._wrap_method( - self.get_branch_rule, - default_timeout=None, - client_info=client_info, - ), - self.update_branch_rule: self._wrap_method( - self.update_branch_rule, - default_timeout=None, - client_info=client_info, - ), - self.delete_branch_rule: self._wrap_method( - self.delete_branch_rule, + @property + def create_pull_request( + self, + ) -> Callable[ + [secure_source_manager.CreatePullRequestRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the create pull request method over gRPC. + + Creates a pull request. + + Returns: + Callable[[~.CreatePullRequestRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_pull_request" not in self._stubs: + self._stubs["create_pull_request"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreatePullRequest", + request_serializer=secure_source_manager.CreatePullRequestRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_pull_request"] + + @property + def get_pull_request( + self, + ) -> Callable[ + [secure_source_manager.GetPullRequestRequest], + Awaitable[secure_source_manager.PullRequest], + ]: + r"""Return a callable for the get pull request method over gRPC. + + Gets a pull request. + + Returns: + Callable[[~.GetPullRequestRequest], + Awaitable[~.PullRequest]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_pull_request" not in self._stubs: + self._stubs["get_pull_request"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetPullRequest", + request_serializer=secure_source_manager.GetPullRequestRequest.serialize, + response_deserializer=secure_source_manager.PullRequest.deserialize, + ) + return self._stubs["get_pull_request"] + + @property + def list_pull_requests( + self, + ) -> Callable[ + [secure_source_manager.ListPullRequestsRequest], + Awaitable[secure_source_manager.ListPullRequestsResponse], + ]: + r"""Return a callable for the list pull requests method over gRPC. + + Lists pull requests in a repository. + + Returns: + Callable[[~.ListPullRequestsRequest], + Awaitable[~.ListPullRequestsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_pull_requests" not in self._stubs: + self._stubs["list_pull_requests"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListPullRequests", + request_serializer=secure_source_manager.ListPullRequestsRequest.serialize, + response_deserializer=secure_source_manager.ListPullRequestsResponse.deserialize, + ) + return self._stubs["list_pull_requests"] + + @property + def update_pull_request( + self, + ) -> Callable[ + [secure_source_manager.UpdatePullRequestRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the update pull request method over gRPC. + + Updates a pull request. + + Returns: + Callable[[~.UpdatePullRequestRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_pull_request" not in self._stubs: + self._stubs["update_pull_request"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdatePullRequest", + request_serializer=secure_source_manager.UpdatePullRequestRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_pull_request"] + + @property + def merge_pull_request( + self, + ) -> Callable[ + [secure_source_manager.MergePullRequestRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the merge pull request method over gRPC. + + Merges a pull request. + + Returns: + Callable[[~.MergePullRequestRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "merge_pull_request" not in self._stubs: + self._stubs["merge_pull_request"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/MergePullRequest", + request_serializer=secure_source_manager.MergePullRequestRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["merge_pull_request"] + + @property + def open_pull_request( + self, + ) -> Callable[ + [secure_source_manager.OpenPullRequestRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the open pull request method over gRPC. + + Opens a pull request. + + Returns: + Callable[[~.OpenPullRequestRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "open_pull_request" not in self._stubs: + self._stubs["open_pull_request"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/OpenPullRequest", + request_serializer=secure_source_manager.OpenPullRequestRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["open_pull_request"] + + @property + def close_pull_request( + self, + ) -> Callable[ + [secure_source_manager.ClosePullRequestRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the close pull request method over gRPC. + + Closes a pull request without merging. + + Returns: + Callable[[~.ClosePullRequestRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "close_pull_request" not in self._stubs: + self._stubs["close_pull_request"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ClosePullRequest", + request_serializer=secure_source_manager.ClosePullRequestRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["close_pull_request"] + + @property + def list_pull_request_file_diffs( + self, + ) -> Callable[ + [secure_source_manager.ListPullRequestFileDiffsRequest], + Awaitable[secure_source_manager.ListPullRequestFileDiffsResponse], + ]: + r"""Return a callable for the list pull request file diffs method over gRPC. + + Lists a pull request's file diffs. + + Returns: + Callable[[~.ListPullRequestFileDiffsRequest], + Awaitable[~.ListPullRequestFileDiffsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_pull_request_file_diffs" not in self._stubs: + self._stubs[ + "list_pull_request_file_diffs" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListPullRequestFileDiffs", + request_serializer=secure_source_manager.ListPullRequestFileDiffsRequest.serialize, + response_deserializer=secure_source_manager.ListPullRequestFileDiffsResponse.deserialize, + ) + return self._stubs["list_pull_request_file_diffs"] + + @property + def fetch_tree( + self, + ) -> Callable[ + [secure_source_manager.FetchTreeRequest], + Awaitable[secure_source_manager.FetchTreeResponse], + ]: + r"""Return a callable for the fetch tree method over gRPC. + + Fetches a tree from a repository. + + Returns: + Callable[[~.FetchTreeRequest], + Awaitable[~.FetchTreeResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "fetch_tree" not in self._stubs: + self._stubs["fetch_tree"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/FetchTree", + request_serializer=secure_source_manager.FetchTreeRequest.serialize, + response_deserializer=secure_source_manager.FetchTreeResponse.deserialize, + ) + return self._stubs["fetch_tree"] + + @property + def fetch_blob( + self, + ) -> Callable[ + [secure_source_manager.FetchBlobRequest], + Awaitable[secure_source_manager.FetchBlobResponse], + ]: + r"""Return a callable for the fetch blob method over gRPC. + + Fetches a blob from a repository. + + Returns: + Callable[[~.FetchBlobRequest], + Awaitable[~.FetchBlobResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "fetch_blob" not in self._stubs: + self._stubs["fetch_blob"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/FetchBlob", + request_serializer=secure_source_manager.FetchBlobRequest.serialize, + response_deserializer=secure_source_manager.FetchBlobResponse.deserialize, + ) + return self._stubs["fetch_blob"] + + @property + def create_issue( + self, + ) -> Callable[ + [secure_source_manager.CreateIssueRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the create issue method over gRPC. + + Creates an issue. + + Returns: + Callable[[~.CreateIssueRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_issue" not in self._stubs: + self._stubs["create_issue"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateIssue", + request_serializer=secure_source_manager.CreateIssueRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_issue"] + + @property + def get_issue( + self, + ) -> Callable[ + [secure_source_manager.GetIssueRequest], Awaitable[secure_source_manager.Issue] + ]: + r"""Return a callable for the get issue method over gRPC. + + Gets an issue. + + Returns: + Callable[[~.GetIssueRequest], + Awaitable[~.Issue]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_issue" not in self._stubs: + self._stubs["get_issue"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetIssue", + request_serializer=secure_source_manager.GetIssueRequest.serialize, + response_deserializer=secure_source_manager.Issue.deserialize, + ) + return self._stubs["get_issue"] + + @property + def list_issues( + self, + ) -> Callable[ + [secure_source_manager.ListIssuesRequest], + Awaitable[secure_source_manager.ListIssuesResponse], + ]: + r"""Return a callable for the list issues method over gRPC. + + Lists issues in a repository. + + Returns: + Callable[[~.ListIssuesRequest], + Awaitable[~.ListIssuesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_issues" not in self._stubs: + self._stubs["list_issues"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListIssues", + request_serializer=secure_source_manager.ListIssuesRequest.serialize, + response_deserializer=secure_source_manager.ListIssuesResponse.deserialize, + ) + return self._stubs["list_issues"] + + @property + def update_issue( + self, + ) -> Callable[ + [secure_source_manager.UpdateIssueRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the update issue method over gRPC. + + Updates a issue. + + Returns: + Callable[[~.UpdateIssueRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_issue" not in self._stubs: + self._stubs["update_issue"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdateIssue", + request_serializer=secure_source_manager.UpdateIssueRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_issue"] + + @property + def delete_issue( + self, + ) -> Callable[ + [secure_source_manager.DeleteIssueRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the delete issue method over gRPC. + + Deletes an issue. + + Returns: + Callable[[~.DeleteIssueRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_issue" not in self._stubs: + self._stubs["delete_issue"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteIssue", + request_serializer=secure_source_manager.DeleteIssueRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_issue"] + + @property + def open_issue( + self, + ) -> Callable[ + [secure_source_manager.OpenIssueRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the open issue method over gRPC. + + Opens an issue. + + Returns: + Callable[[~.OpenIssueRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "open_issue" not in self._stubs: + self._stubs["open_issue"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/OpenIssue", + request_serializer=secure_source_manager.OpenIssueRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["open_issue"] + + @property + def close_issue( + self, + ) -> Callable[ + [secure_source_manager.CloseIssueRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the close issue method over gRPC. + + Closes an issue. + + Returns: + Callable[[~.CloseIssueRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "close_issue" not in self._stubs: + self._stubs["close_issue"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/CloseIssue", + request_serializer=secure_source_manager.CloseIssueRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["close_issue"] + + @property + def get_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.GetPullRequestCommentRequest], + Awaitable[secure_source_manager.PullRequestComment], + ]: + r"""Return a callable for the get pull request comment method over gRPC. + + Gets a pull request comment. + + Returns: + Callable[[~.GetPullRequestCommentRequest], + Awaitable[~.PullRequestComment]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_pull_request_comment" not in self._stubs: + self._stubs["get_pull_request_comment"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetPullRequestComment", + request_serializer=secure_source_manager.GetPullRequestCommentRequest.serialize, + response_deserializer=secure_source_manager.PullRequestComment.deserialize, + ) + return self._stubs["get_pull_request_comment"] + + @property + def list_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.ListPullRequestCommentsRequest], + Awaitable[secure_source_manager.ListPullRequestCommentsResponse], + ]: + r"""Return a callable for the list pull request comments method over gRPC. + + Lists pull request comments. + + Returns: + Callable[[~.ListPullRequestCommentsRequest], + Awaitable[~.ListPullRequestCommentsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_pull_request_comments" not in self._stubs: + self._stubs[ + "list_pull_request_comments" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListPullRequestComments", + request_serializer=secure_source_manager.ListPullRequestCommentsRequest.serialize, + response_deserializer=secure_source_manager.ListPullRequestCommentsResponse.deserialize, + ) + return self._stubs["list_pull_request_comments"] + + @property + def create_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.CreatePullRequestCommentRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the create pull request comment method over gRPC. + + Creates a pull request comment. + + Returns: + Callable[[~.CreatePullRequestCommentRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_pull_request_comment" not in self._stubs: + self._stubs[ + "create_pull_request_comment" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreatePullRequestComment", + request_serializer=secure_source_manager.CreatePullRequestCommentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_pull_request_comment"] + + @property + def update_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.UpdatePullRequestCommentRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the update pull request comment method over gRPC. + + Updates a pull request comment. + + Returns: + Callable[[~.UpdatePullRequestCommentRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_pull_request_comment" not in self._stubs: + self._stubs[ + "update_pull_request_comment" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdatePullRequestComment", + request_serializer=secure_source_manager.UpdatePullRequestCommentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_pull_request_comment"] + + @property + def delete_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.DeletePullRequestCommentRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the delete pull request comment method over gRPC. + + Deletes a pull request comment. + + Returns: + Callable[[~.DeletePullRequestCommentRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_pull_request_comment" not in self._stubs: + self._stubs[ + "delete_pull_request_comment" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeletePullRequestComment", + request_serializer=secure_source_manager.DeletePullRequestCommentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_pull_request_comment"] + + @property + def batch_create_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.BatchCreatePullRequestCommentsRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the batch create pull request + comments method over gRPC. + + Batch creates pull request comments. + + Returns: + Callable[[~.BatchCreatePullRequestCommentsRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "batch_create_pull_request_comments" not in self._stubs: + self._stubs[ + "batch_create_pull_request_comments" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/BatchCreatePullRequestComments", + request_serializer=secure_source_manager.BatchCreatePullRequestCommentsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["batch_create_pull_request_comments"] + + @property + def resolve_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.ResolvePullRequestCommentsRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the resolve pull request comments method over gRPC. + + Resolves pull request comments. + + Returns: + Callable[[~.ResolvePullRequestCommentsRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "resolve_pull_request_comments" not in self._stubs: + self._stubs[ + "resolve_pull_request_comments" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ResolvePullRequestComments", + request_serializer=secure_source_manager.ResolvePullRequestCommentsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["resolve_pull_request_comments"] + + @property + def unresolve_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.UnresolvePullRequestCommentsRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the unresolve pull request + comments method over gRPC. + + Unresolves pull request comment. + + Returns: + Callable[[~.UnresolvePullRequestCommentsRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "unresolve_pull_request_comments" not in self._stubs: + self._stubs[ + "unresolve_pull_request_comments" + ] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UnresolvePullRequestComments", + request_serializer=secure_source_manager.UnresolvePullRequestCommentsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["unresolve_pull_request_comments"] + + @property + def create_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.CreateIssueCommentRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the create issue comment method over gRPC. + + Creates an issue comment. + + Returns: + Callable[[~.CreateIssueCommentRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_issue_comment" not in self._stubs: + self._stubs["create_issue_comment"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateIssueComment", + request_serializer=secure_source_manager.CreateIssueCommentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_issue_comment"] + + @property + def get_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.GetIssueCommentRequest], + Awaitable[secure_source_manager.IssueComment], + ]: + r"""Return a callable for the get issue comment method over gRPC. + + Gets an issue comment. + + Returns: + Callable[[~.GetIssueCommentRequest], + Awaitable[~.IssueComment]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_issue_comment" not in self._stubs: + self._stubs["get_issue_comment"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/GetIssueComment", + request_serializer=secure_source_manager.GetIssueCommentRequest.serialize, + response_deserializer=secure_source_manager.IssueComment.deserialize, + ) + return self._stubs["get_issue_comment"] + + @property + def list_issue_comments( + self, + ) -> Callable[ + [secure_source_manager.ListIssueCommentsRequest], + Awaitable[secure_source_manager.ListIssueCommentsResponse], + ]: + r"""Return a callable for the list issue comments method over gRPC. + + Lists comments in an issue. + + Returns: + Callable[[~.ListIssueCommentsRequest], + Awaitable[~.ListIssueCommentsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_issue_comments" not in self._stubs: + self._stubs["list_issue_comments"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/ListIssueComments", + request_serializer=secure_source_manager.ListIssueCommentsRequest.serialize, + response_deserializer=secure_source_manager.ListIssueCommentsResponse.deserialize, + ) + return self._stubs["list_issue_comments"] + + @property + def update_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.UpdateIssueCommentRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the update issue comment method over gRPC. + + Updates an issue comment. + + Returns: + Callable[[~.UpdateIssueCommentRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_issue_comment" not in self._stubs: + self._stubs["update_issue_comment"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdateIssueComment", + request_serializer=secure_source_manager.UpdateIssueCommentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_issue_comment"] + + @property + def delete_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.DeleteIssueCommentRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the delete issue comment method over gRPC. + + Deletes an issue comment. + + Returns: + Callable[[~.DeleteIssueCommentRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_issue_comment" not in self._stubs: + self._stubs["delete_issue_comment"] = self._logged_channel.unary_unary( + "/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteIssueComment", + request_serializer=secure_source_manager.DeleteIssueCommentRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_issue_comment"] + + def _prep_wrapped_messages(self, client_info): + """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" + self._wrapped_methods = { + self.list_instances: self._wrap_method( + self.list_instances, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_instance: self._wrap_method( + self.get_instance, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_instance: self._wrap_method( + self.create_instance, + default_timeout=None, + client_info=client_info, + ), + self.delete_instance: self._wrap_method( + self.delete_instance, + default_timeout=None, + client_info=client_info, + ), + self.list_repositories: self._wrap_method( + self.list_repositories, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_repository: self._wrap_method( + self.get_repository, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_repository: self._wrap_method( + self.create_repository, + default_timeout=None, + client_info=client_info, + ), + self.update_repository: self._wrap_method( + self.update_repository, + default_timeout=None, + client_info=client_info, + ), + self.delete_repository: self._wrap_method( + self.delete_repository, + default_timeout=None, + client_info=client_info, + ), + self.list_hooks: self._wrap_method( + self.list_hooks, + default_timeout=None, + client_info=client_info, + ), + self.get_hook: self._wrap_method( + self.get_hook, + default_timeout=None, + client_info=client_info, + ), + self.create_hook: self._wrap_method( + self.create_hook, + default_timeout=None, + client_info=client_info, + ), + self.update_hook: self._wrap_method( + self.update_hook, + default_timeout=None, + client_info=client_info, + ), + self.delete_hook: self._wrap_method( + self.delete_hook, + default_timeout=None, + client_info=client_info, + ), + self.get_iam_policy_repo: self._wrap_method( + self.get_iam_policy_repo, + default_retry=retries.AsyncRetry( + initial=1.0, + maximum=10.0, + multiplier=1.3, + predicate=retries.if_exception_type( + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.set_iam_policy_repo: self._wrap_method( + self.set_iam_policy_repo, + default_timeout=None, + client_info=client_info, + ), + self.test_iam_permissions_repo: self._wrap_method( + self.test_iam_permissions_repo, + default_timeout=None, + client_info=client_info, + ), + self.create_branch_rule: self._wrap_method( + self.create_branch_rule, + default_timeout=None, + client_info=client_info, + ), + self.list_branch_rules: self._wrap_method( + self.list_branch_rules, + default_timeout=None, + client_info=client_info, + ), + self.get_branch_rule: self._wrap_method( + self.get_branch_rule, + default_timeout=None, + client_info=client_info, + ), + self.update_branch_rule: self._wrap_method( + self.update_branch_rule, + default_timeout=None, + client_info=client_info, + ), + self.delete_branch_rule: self._wrap_method( + self.delete_branch_rule, + default_timeout=None, + client_info=client_info, + ), + self.create_pull_request: self._wrap_method( + self.create_pull_request, + default_timeout=None, + client_info=client_info, + ), + self.get_pull_request: self._wrap_method( + self.get_pull_request, + default_timeout=None, + client_info=client_info, + ), + self.list_pull_requests: self._wrap_method( + self.list_pull_requests, + default_timeout=None, + client_info=client_info, + ), + self.update_pull_request: self._wrap_method( + self.update_pull_request, + default_timeout=None, + client_info=client_info, + ), + self.merge_pull_request: self._wrap_method( + self.merge_pull_request, + default_timeout=None, + client_info=client_info, + ), + self.open_pull_request: self._wrap_method( + self.open_pull_request, + default_timeout=None, + client_info=client_info, + ), + self.close_pull_request: self._wrap_method( + self.close_pull_request, + default_timeout=None, + client_info=client_info, + ), + self.list_pull_request_file_diffs: self._wrap_method( + self.list_pull_request_file_diffs, + default_timeout=None, + client_info=client_info, + ), + self.fetch_tree: self._wrap_method( + self.fetch_tree, + default_timeout=None, + client_info=client_info, + ), + self.fetch_blob: self._wrap_method( + self.fetch_blob, + default_timeout=None, + client_info=client_info, + ), + self.create_issue: self._wrap_method( + self.create_issue, + default_timeout=None, + client_info=client_info, + ), + self.get_issue: self._wrap_method( + self.get_issue, + default_timeout=None, + client_info=client_info, + ), + self.list_issues: self._wrap_method( + self.list_issues, + default_timeout=None, + client_info=client_info, + ), + self.update_issue: self._wrap_method( + self.update_issue, + default_timeout=None, + client_info=client_info, + ), + self.delete_issue: self._wrap_method( + self.delete_issue, + default_timeout=None, + client_info=client_info, + ), + self.open_issue: self._wrap_method( + self.open_issue, + default_timeout=None, + client_info=client_info, + ), + self.close_issue: self._wrap_method( + self.close_issue, + default_timeout=None, + client_info=client_info, + ), + self.get_pull_request_comment: self._wrap_method( + self.get_pull_request_comment, + default_timeout=None, + client_info=client_info, + ), + self.list_pull_request_comments: self._wrap_method( + self.list_pull_request_comments, + default_timeout=None, + client_info=client_info, + ), + self.create_pull_request_comment: self._wrap_method( + self.create_pull_request_comment, + default_timeout=None, + client_info=client_info, + ), + self.update_pull_request_comment: self._wrap_method( + self.update_pull_request_comment, + default_timeout=None, + client_info=client_info, + ), + self.delete_pull_request_comment: self._wrap_method( + self.delete_pull_request_comment, + default_timeout=None, + client_info=client_info, + ), + self.batch_create_pull_request_comments: self._wrap_method( + self.batch_create_pull_request_comments, + default_timeout=None, + client_info=client_info, + ), + self.resolve_pull_request_comments: self._wrap_method( + self.resolve_pull_request_comments, + default_timeout=None, + client_info=client_info, + ), + self.unresolve_pull_request_comments: self._wrap_method( + self.unresolve_pull_request_comments, + default_timeout=None, + client_info=client_info, + ), + self.create_issue_comment: self._wrap_method( + self.create_issue_comment, + default_timeout=None, + client_info=client_info, + ), + self.get_issue_comment: self._wrap_method( + self.get_issue_comment, + default_timeout=None, + client_info=client_info, + ), + self.list_issue_comments: self._wrap_method( + self.list_issue_comments, + default_timeout=None, + client_info=client_info, + ), + self.update_issue_comment: self._wrap_method( + self.update_issue_comment, + default_timeout=None, + client_info=client_info, + ), + self.delete_issue_comment: self._wrap_method( + self.delete_issue_comment, default_timeout=None, client_info=client_info, ), diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/rest.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/rest.py index 0077ab71a09f..3783fa337654 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/rest.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/rest.py @@ -76,6 +76,30 @@ class SecureSourceManagerRestInterceptor: .. code-block:: python class MyCustomSecureSourceManagerInterceptor(SecureSourceManagerRestInterceptor): + def pre_batch_create_pull_request_comments(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_batch_create_pull_request_comments(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_close_issue(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_close_issue(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_close_pull_request(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_close_pull_request(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_branch_rule(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -84,6 +108,14 @@ def post_create_branch_rule(self, response): logging.log(f"Received response: {response}") return response + def pre_create_hook(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_hook(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_instance(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -92,6 +124,38 @@ def post_create_instance(self, response): logging.log(f"Received response: {response}") return response + def pre_create_issue(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_issue(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_issue_comment(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_issue_comment(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_pull_request(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_pull_request(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_pull_request_comment(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_pull_request_comment(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_repository(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -108,6 +172,14 @@ def post_delete_branch_rule(self, response): logging.log(f"Received response: {response}") return response + def pre_delete_hook(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_hook(self, response): + logging.log(f"Received response: {response}") + return response + def pre_delete_instance(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -116,6 +188,30 @@ def post_delete_instance(self, response): logging.log(f"Received response: {response}") return response + def pre_delete_issue(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_issue(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_issue_comment(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_issue_comment(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_pull_request_comment(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_pull_request_comment(self, response): + logging.log(f"Received response: {response}") + return response + def pre_delete_repository(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -124,6 +220,22 @@ def post_delete_repository(self, response): logging.log(f"Received response: {response}") return response + def pre_fetch_blob(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_fetch_blob(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_fetch_tree(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_fetch_tree(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_branch_rule(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -132,6 +244,14 @@ def post_get_branch_rule(self, response): logging.log(f"Received response: {response}") return response + def pre_get_hook(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_hook(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_iam_policy_repo(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -148,6 +268,38 @@ def post_get_instance(self, response): logging.log(f"Received response: {response}") return response + def pre_get_issue(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_issue(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_issue_comment(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_issue_comment(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_pull_request(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_pull_request(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_pull_request_comment(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_pull_request_comment(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_repository(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -164,6 +316,14 @@ def post_list_branch_rules(self, response): logging.log(f"Received response: {response}") return response + def pre_list_hooks(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_hooks(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_instances(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -172,6 +332,46 @@ def post_list_instances(self, response): logging.log(f"Received response: {response}") return response + def pre_list_issue_comments(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_issue_comments(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_issues(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_issues(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_pull_request_comments(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_pull_request_comments(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_pull_request_file_diffs(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_pull_request_file_diffs(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_pull_requests(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_pull_requests(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_repositories(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -180,6 +380,38 @@ def post_list_repositories(self, response): logging.log(f"Received response: {response}") return response + def pre_merge_pull_request(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_merge_pull_request(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_open_issue(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_open_issue(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_open_pull_request(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_open_pull_request(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_resolve_pull_request_comments(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_resolve_pull_request_comments(self, response): + logging.log(f"Received response: {response}") + return response + def pre_set_iam_policy_repo(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -196,6 +428,14 @@ def post_test_iam_permissions_repo(self, response): logging.log(f"Received response: {response}") return response + def pre_unresolve_pull_request_comments(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_unresolve_pull_request_comments(self, response): + logging.log(f"Received response: {response}") + return response + def pre_update_branch_rule(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -204,1199 +444,8385 @@ def post_update_branch_rule(self, response): logging.log(f"Received response: {response}") return response + def pre_update_hook(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_hook(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_issue(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_issue(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_issue_comment(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_issue_comment(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_pull_request(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_pull_request(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_pull_request_comment(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_pull_request_comment(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_repository(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_repository(self, response): + logging.log(f"Received response: {response}") + return response + transport = SecureSourceManagerRestTransport(interceptor=MyCustomSecureSourceManagerInterceptor()) client = SecureSourceManagerClient(transport=transport) """ - def pre_create_branch_rule( + def pre_batch_create_pull_request_comments( self, - request: secure_source_manager.CreateBranchRuleRequest, + request: secure_source_manager.BatchCreatePullRequestCommentsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.CreateBranchRuleRequest, + secure_source_manager.BatchCreatePullRequestCommentsRequest, Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for create_branch_rule + """Pre-rpc interceptor for batch_create_pull_request_comments Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_create_branch_rule( + def post_batch_create_pull_request_comments( self, response: operations_pb2.Operation ) -> operations_pb2.Operation: - """Post-rpc interceptor for create_branch_rule + """Post-rpc interceptor for batch_create_pull_request_comments - DEPRECATED. Please use the `post_create_branch_rule_with_metadata` + DEPRECATED. Please use the `post_batch_create_pull_request_comments_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_create_branch_rule` interceptor runs - before the `post_create_branch_rule_with_metadata` interceptor. + it is returned to user code. This `post_batch_create_pull_request_comments` interceptor runs + before the `post_batch_create_pull_request_comments_with_metadata` interceptor. """ return response - def post_create_branch_rule_with_metadata( + def post_batch_create_pull_request_comments_with_metadata( self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_branch_rule + """Post-rpc interceptor for batch_create_pull_request_comments Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_create_branch_rule_with_metadata` - interceptor in new development instead of the `post_create_branch_rule` interceptor. - When both interceptors are used, this `post_create_branch_rule_with_metadata` interceptor runs after the - `post_create_branch_rule` interceptor. The (possibly modified) response returned by - `post_create_branch_rule` will be passed to - `post_create_branch_rule_with_metadata`. + We recommend only using this `post_batch_create_pull_request_comments_with_metadata` + interceptor in new development instead of the `post_batch_create_pull_request_comments` interceptor. + When both interceptors are used, this `post_batch_create_pull_request_comments_with_metadata` interceptor runs after the + `post_batch_create_pull_request_comments` interceptor. The (possibly modified) response returned by + `post_batch_create_pull_request_comments` will be passed to + `post_batch_create_pull_request_comments_with_metadata`. """ return response, metadata - def pre_create_instance( + def pre_close_issue( self, - request: secure_source_manager.CreateInstanceRequest, + request: secure_source_manager.CloseIssueRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.CreateInstanceRequest, - Sequence[Tuple[str, Union[str, bytes]]], + secure_source_manager.CloseIssueRequest, Sequence[Tuple[str, Union[str, bytes]]] ]: - """Pre-rpc interceptor for create_instance + """Pre-rpc interceptor for close_issue Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_create_instance( + def post_close_issue( self, response: operations_pb2.Operation ) -> operations_pb2.Operation: - """Post-rpc interceptor for create_instance + """Post-rpc interceptor for close_issue - DEPRECATED. Please use the `post_create_instance_with_metadata` + DEPRECATED. Please use the `post_close_issue_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_create_instance` interceptor runs - before the `post_create_instance_with_metadata` interceptor. + it is returned to user code. This `post_close_issue` interceptor runs + before the `post_close_issue_with_metadata` interceptor. """ return response - def post_create_instance_with_metadata( + def post_close_issue_with_metadata( self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_instance + """Post-rpc interceptor for close_issue Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_create_instance_with_metadata` - interceptor in new development instead of the `post_create_instance` interceptor. - When both interceptors are used, this `post_create_instance_with_metadata` interceptor runs after the - `post_create_instance` interceptor. The (possibly modified) response returned by - `post_create_instance` will be passed to - `post_create_instance_with_metadata`. + We recommend only using this `post_close_issue_with_metadata` + interceptor in new development instead of the `post_close_issue` interceptor. + When both interceptors are used, this `post_close_issue_with_metadata` interceptor runs after the + `post_close_issue` interceptor. The (possibly modified) response returned by + `post_close_issue` will be passed to + `post_close_issue_with_metadata`. """ return response, metadata - def pre_create_repository( + def pre_close_pull_request( self, - request: secure_source_manager.CreateRepositoryRequest, + request: secure_source_manager.ClosePullRequestRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.CreateRepositoryRequest, + secure_source_manager.ClosePullRequestRequest, Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for create_repository + """Pre-rpc interceptor for close_pull_request Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_create_repository( + def post_close_pull_request( self, response: operations_pb2.Operation ) -> operations_pb2.Operation: - """Post-rpc interceptor for create_repository + """Post-rpc interceptor for close_pull_request - DEPRECATED. Please use the `post_create_repository_with_metadata` + DEPRECATED. Please use the `post_close_pull_request_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_create_repository` interceptor runs - before the `post_create_repository_with_metadata` interceptor. + it is returned to user code. This `post_close_pull_request` interceptor runs + before the `post_close_pull_request_with_metadata` interceptor. """ return response - def post_create_repository_with_metadata( + def post_close_pull_request_with_metadata( self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_repository + """Post-rpc interceptor for close_pull_request Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_create_repository_with_metadata` - interceptor in new development instead of the `post_create_repository` interceptor. - When both interceptors are used, this `post_create_repository_with_metadata` interceptor runs after the - `post_create_repository` interceptor. The (possibly modified) response returned by - `post_create_repository` will be passed to - `post_create_repository_with_metadata`. + We recommend only using this `post_close_pull_request_with_metadata` + interceptor in new development instead of the `post_close_pull_request` interceptor. + When both interceptors are used, this `post_close_pull_request_with_metadata` interceptor runs after the + `post_close_pull_request` interceptor. The (possibly modified) response returned by + `post_close_pull_request` will be passed to + `post_close_pull_request_with_metadata`. """ return response, metadata - def pre_delete_branch_rule( + def pre_create_branch_rule( self, - request: secure_source_manager.DeleteBranchRuleRequest, + request: secure_source_manager.CreateBranchRuleRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.DeleteBranchRuleRequest, + secure_source_manager.CreateBranchRuleRequest, Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for delete_branch_rule + """Pre-rpc interceptor for create_branch_rule Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_delete_branch_rule( + def post_create_branch_rule( self, response: operations_pb2.Operation ) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_branch_rule + """Post-rpc interceptor for create_branch_rule - DEPRECATED. Please use the `post_delete_branch_rule_with_metadata` + DEPRECATED. Please use the `post_create_branch_rule_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_delete_branch_rule` interceptor runs - before the `post_delete_branch_rule_with_metadata` interceptor. + it is returned to user code. This `post_create_branch_rule` interceptor runs + before the `post_create_branch_rule_with_metadata` interceptor. """ return response - def post_delete_branch_rule_with_metadata( + def post_create_branch_rule_with_metadata( self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_branch_rule + """Post-rpc interceptor for create_branch_rule Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_delete_branch_rule_with_metadata` - interceptor in new development instead of the `post_delete_branch_rule` interceptor. - When both interceptors are used, this `post_delete_branch_rule_with_metadata` interceptor runs after the - `post_delete_branch_rule` interceptor. The (possibly modified) response returned by - `post_delete_branch_rule` will be passed to - `post_delete_branch_rule_with_metadata`. + We recommend only using this `post_create_branch_rule_with_metadata` + interceptor in new development instead of the `post_create_branch_rule` interceptor. + When both interceptors are used, this `post_create_branch_rule_with_metadata` interceptor runs after the + `post_create_branch_rule` interceptor. The (possibly modified) response returned by + `post_create_branch_rule` will be passed to + `post_create_branch_rule_with_metadata`. """ return response, metadata - def pre_delete_instance( + def pre_create_hook( self, - request: secure_source_manager.DeleteInstanceRequest, + request: secure_source_manager.CreateHookRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.DeleteInstanceRequest, - Sequence[Tuple[str, Union[str, bytes]]], + secure_source_manager.CreateHookRequest, Sequence[Tuple[str, Union[str, bytes]]] ]: - """Pre-rpc interceptor for delete_instance + """Pre-rpc interceptor for create_hook Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_delete_instance( + def post_create_hook( self, response: operations_pb2.Operation ) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_instance + """Post-rpc interceptor for create_hook - DEPRECATED. Please use the `post_delete_instance_with_metadata` + DEPRECATED. Please use the `post_create_hook_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_delete_instance` interceptor runs - before the `post_delete_instance_with_metadata` interceptor. + it is returned to user code. This `post_create_hook` interceptor runs + before the `post_create_hook_with_metadata` interceptor. """ return response - def post_delete_instance_with_metadata( + def post_create_hook_with_metadata( self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_instance + """Post-rpc interceptor for create_hook Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_delete_instance_with_metadata` - interceptor in new development instead of the `post_delete_instance` interceptor. - When both interceptors are used, this `post_delete_instance_with_metadata` interceptor runs after the - `post_delete_instance` interceptor. The (possibly modified) response returned by - `post_delete_instance` will be passed to - `post_delete_instance_with_metadata`. + We recommend only using this `post_create_hook_with_metadata` + interceptor in new development instead of the `post_create_hook` interceptor. + When both interceptors are used, this `post_create_hook_with_metadata` interceptor runs after the + `post_create_hook` interceptor. The (possibly modified) response returned by + `post_create_hook` will be passed to + `post_create_hook_with_metadata`. """ return response, metadata - def pre_delete_repository( + def pre_create_instance( self, - request: secure_source_manager.DeleteRepositoryRequest, + request: secure_source_manager.CreateInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.DeleteRepositoryRequest, + secure_source_manager.CreateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for delete_repository + """Pre-rpc interceptor for create_instance Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_delete_repository( + def post_create_instance( self, response: operations_pb2.Operation ) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_repository + """Post-rpc interceptor for create_instance - DEPRECATED. Please use the `post_delete_repository_with_metadata` + DEPRECATED. Please use the `post_create_instance_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_delete_repository` interceptor runs - before the `post_delete_repository_with_metadata` interceptor. + it is returned to user code. This `post_create_instance` interceptor runs + before the `post_create_instance_with_metadata` interceptor. """ return response - def post_delete_repository_with_metadata( + def post_create_instance_with_metadata( self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_repository + """Post-rpc interceptor for create_instance Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_delete_repository_with_metadata` - interceptor in new development instead of the `post_delete_repository` interceptor. - When both interceptors are used, this `post_delete_repository_with_metadata` interceptor runs after the - `post_delete_repository` interceptor. The (possibly modified) response returned by - `post_delete_repository` will be passed to - `post_delete_repository_with_metadata`. + We recommend only using this `post_create_instance_with_metadata` + interceptor in new development instead of the `post_create_instance` interceptor. + When both interceptors are used, this `post_create_instance_with_metadata` interceptor runs after the + `post_create_instance` interceptor. The (possibly modified) response returned by + `post_create_instance` will be passed to + `post_create_instance_with_metadata`. """ return response, metadata - def pre_get_branch_rule( + def pre_create_issue( self, - request: secure_source_manager.GetBranchRuleRequest, + request: secure_source_manager.CreateIssueRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.GetBranchRuleRequest, + secure_source_manager.CreateIssueRequest, Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for get_branch_rule + """Pre-rpc interceptor for create_issue Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_get_branch_rule( - self, response: secure_source_manager.BranchRule - ) -> secure_source_manager.BranchRule: - """Post-rpc interceptor for get_branch_rule + def post_create_issue( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for create_issue - DEPRECATED. Please use the `post_get_branch_rule_with_metadata` + DEPRECATED. Please use the `post_create_issue_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_get_branch_rule` interceptor runs - before the `post_get_branch_rule_with_metadata` interceptor. + it is returned to user code. This `post_create_issue` interceptor runs + before the `post_create_issue_with_metadata` interceptor. """ return response - def post_get_branch_rule_with_metadata( + def post_create_issue_with_metadata( self, - response: secure_source_manager.BranchRule, + response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - secure_source_manager.BranchRule, Sequence[Tuple[str, Union[str, bytes]]] - ]: - """Post-rpc interceptor for get_branch_rule + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_issue Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_get_branch_rule_with_metadata` - interceptor in new development instead of the `post_get_branch_rule` interceptor. - When both interceptors are used, this `post_get_branch_rule_with_metadata` interceptor runs after the - `post_get_branch_rule` interceptor. The (possibly modified) response returned by - `post_get_branch_rule` will be passed to - `post_get_branch_rule_with_metadata`. + We recommend only using this `post_create_issue_with_metadata` + interceptor in new development instead of the `post_create_issue` interceptor. + When both interceptors are used, this `post_create_issue_with_metadata` interceptor runs after the + `post_create_issue` interceptor. The (possibly modified) response returned by + `post_create_issue` will be passed to + `post_create_issue_with_metadata`. """ return response, metadata - def pre_get_iam_policy_repo( + def pre_create_issue_comment( self, - request: iam_policy_pb2.GetIamPolicyRequest, + request: secure_source_manager.CreateIssueCommentRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + secure_source_manager.CreateIssueCommentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for get_iam_policy_repo + """Pre-rpc interceptor for create_issue_comment Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_get_iam_policy_repo( - self, response: policy_pb2.Policy - ) -> policy_pb2.Policy: - """Post-rpc interceptor for get_iam_policy_repo + def post_create_issue_comment( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for create_issue_comment - DEPRECATED. Please use the `post_get_iam_policy_repo_with_metadata` + DEPRECATED. Please use the `post_create_issue_comment_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_get_iam_policy_repo` interceptor runs - before the `post_get_iam_policy_repo_with_metadata` interceptor. + it is returned to user code. This `post_create_issue_comment` interceptor runs + before the `post_create_issue_comment_with_metadata` interceptor. """ return response - def post_get_iam_policy_repo_with_metadata( + def post_create_issue_comment_with_metadata( self, - response: policy_pb2.Policy, + response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[policy_pb2.Policy, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_iam_policy_repo + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_issue_comment Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_get_iam_policy_repo_with_metadata` - interceptor in new development instead of the `post_get_iam_policy_repo` interceptor. - When both interceptors are used, this `post_get_iam_policy_repo_with_metadata` interceptor runs after the - `post_get_iam_policy_repo` interceptor. The (possibly modified) response returned by - `post_get_iam_policy_repo` will be passed to - `post_get_iam_policy_repo_with_metadata`. + We recommend only using this `post_create_issue_comment_with_metadata` + interceptor in new development instead of the `post_create_issue_comment` interceptor. + When both interceptors are used, this `post_create_issue_comment_with_metadata` interceptor runs after the + `post_create_issue_comment` interceptor. The (possibly modified) response returned by + `post_create_issue_comment` will be passed to + `post_create_issue_comment_with_metadata`. """ return response, metadata - def pre_get_instance( + def pre_create_pull_request( self, - request: secure_source_manager.GetInstanceRequest, + request: secure_source_manager.CreatePullRequestRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.GetInstanceRequest, + secure_source_manager.CreatePullRequestRequest, Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for get_instance + """Pre-rpc interceptor for create_pull_request Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_get_instance( - self, response: secure_source_manager.Instance - ) -> secure_source_manager.Instance: - """Post-rpc interceptor for get_instance + def post_create_pull_request( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for create_pull_request - DEPRECATED. Please use the `post_get_instance_with_metadata` + DEPRECATED. Please use the `post_create_pull_request_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_get_instance` interceptor runs - before the `post_get_instance_with_metadata` interceptor. + it is returned to user code. This `post_create_pull_request` interceptor runs + before the `post_create_pull_request_with_metadata` interceptor. """ return response - def post_get_instance_with_metadata( + def post_create_pull_request_with_metadata( self, - response: secure_source_manager.Instance, + response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[secure_source_manager.Instance, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_instance + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_pull_request Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_get_instance_with_metadata` - interceptor in new development instead of the `post_get_instance` interceptor. - When both interceptors are used, this `post_get_instance_with_metadata` interceptor runs after the - `post_get_instance` interceptor. The (possibly modified) response returned by - `post_get_instance` will be passed to - `post_get_instance_with_metadata`. + We recommend only using this `post_create_pull_request_with_metadata` + interceptor in new development instead of the `post_create_pull_request` interceptor. + When both interceptors are used, this `post_create_pull_request_with_metadata` interceptor runs after the + `post_create_pull_request` interceptor. The (possibly modified) response returned by + `post_create_pull_request` will be passed to + `post_create_pull_request_with_metadata`. """ return response, metadata - def pre_get_repository( + def pre_create_pull_request_comment( self, - request: secure_source_manager.GetRepositoryRequest, + request: secure_source_manager.CreatePullRequestCommentRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.GetRepositoryRequest, + secure_source_manager.CreatePullRequestCommentRequest, Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for get_repository + """Pre-rpc interceptor for create_pull_request_comment Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_get_repository( - self, response: secure_source_manager.Repository - ) -> secure_source_manager.Repository: - """Post-rpc interceptor for get_repository + def post_create_pull_request_comment( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for create_pull_request_comment - DEPRECATED. Please use the `post_get_repository_with_metadata` + DEPRECATED. Please use the `post_create_pull_request_comment_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_get_repository` interceptor runs - before the `post_get_repository_with_metadata` interceptor. + it is returned to user code. This `post_create_pull_request_comment` interceptor runs + before the `post_create_pull_request_comment_with_metadata` interceptor. """ return response - def post_get_repository_with_metadata( + def post_create_pull_request_comment_with_metadata( self, - response: secure_source_manager.Repository, + response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - secure_source_manager.Repository, Sequence[Tuple[str, Union[str, bytes]]] - ]: - """Post-rpc interceptor for get_repository + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_pull_request_comment Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_get_repository_with_metadata` - interceptor in new development instead of the `post_get_repository` interceptor. - When both interceptors are used, this `post_get_repository_with_metadata` interceptor runs after the - `post_get_repository` interceptor. The (possibly modified) response returned by - `post_get_repository` will be passed to - `post_get_repository_with_metadata`. + We recommend only using this `post_create_pull_request_comment_with_metadata` + interceptor in new development instead of the `post_create_pull_request_comment` interceptor. + When both interceptors are used, this `post_create_pull_request_comment_with_metadata` interceptor runs after the + `post_create_pull_request_comment` interceptor. The (possibly modified) response returned by + `post_create_pull_request_comment` will be passed to + `post_create_pull_request_comment_with_metadata`. """ return response, metadata - def pre_list_branch_rules( + def pre_create_repository( self, - request: secure_source_manager.ListBranchRulesRequest, + request: secure_source_manager.CreateRepositoryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.ListBranchRulesRequest, + secure_source_manager.CreateRepositoryRequest, Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for list_branch_rules + """Pre-rpc interceptor for create_repository Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_list_branch_rules( - self, response: secure_source_manager.ListBranchRulesResponse - ) -> secure_source_manager.ListBranchRulesResponse: - """Post-rpc interceptor for list_branch_rules + def post_create_repository( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for create_repository - DEPRECATED. Please use the `post_list_branch_rules_with_metadata` + DEPRECATED. Please use the `post_create_repository_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_list_branch_rules` interceptor runs - before the `post_list_branch_rules_with_metadata` interceptor. + it is returned to user code. This `post_create_repository` interceptor runs + before the `post_create_repository_with_metadata` interceptor. """ return response - def post_list_branch_rules_with_metadata( + def post_create_repository_with_metadata( self, - response: secure_source_manager.ListBranchRulesResponse, + response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - secure_source_manager.ListBranchRulesResponse, - Sequence[Tuple[str, Union[str, bytes]]], - ]: - """Post-rpc interceptor for list_branch_rules + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_repository Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_list_branch_rules_with_metadata` - interceptor in new development instead of the `post_list_branch_rules` interceptor. - When both interceptors are used, this `post_list_branch_rules_with_metadata` interceptor runs after the - `post_list_branch_rules` interceptor. The (possibly modified) response returned by - `post_list_branch_rules` will be passed to - `post_list_branch_rules_with_metadata`. + We recommend only using this `post_create_repository_with_metadata` + interceptor in new development instead of the `post_create_repository` interceptor. + When both interceptors are used, this `post_create_repository_with_metadata` interceptor runs after the + `post_create_repository` interceptor. The (possibly modified) response returned by + `post_create_repository` will be passed to + `post_create_repository_with_metadata`. """ return response, metadata - def pre_list_instances( + def pre_delete_branch_rule( self, - request: secure_source_manager.ListInstancesRequest, + request: secure_source_manager.DeleteBranchRuleRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.ListInstancesRequest, + secure_source_manager.DeleteBranchRuleRequest, Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for list_instances + """Pre-rpc interceptor for delete_branch_rule Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_list_instances( - self, response: secure_source_manager.ListInstancesResponse - ) -> secure_source_manager.ListInstancesResponse: - """Post-rpc interceptor for list_instances + def post_delete_branch_rule( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_branch_rule - DEPRECATED. Please use the `post_list_instances_with_metadata` + DEPRECATED. Please use the `post_delete_branch_rule_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_list_instances` interceptor runs - before the `post_list_instances_with_metadata` interceptor. + it is returned to user code. This `post_delete_branch_rule` interceptor runs + before the `post_delete_branch_rule_with_metadata` interceptor. """ return response - def post_list_instances_with_metadata( + def post_delete_branch_rule_with_metadata( self, - response: secure_source_manager.ListInstancesResponse, + response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - secure_source_manager.ListInstancesResponse, - Sequence[Tuple[str, Union[str, bytes]]], - ]: - """Post-rpc interceptor for list_instances + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_branch_rule Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_list_instances_with_metadata` - interceptor in new development instead of the `post_list_instances` interceptor. - When both interceptors are used, this `post_list_instances_with_metadata` interceptor runs after the - `post_list_instances` interceptor. The (possibly modified) response returned by - `post_list_instances` will be passed to - `post_list_instances_with_metadata`. + We recommend only using this `post_delete_branch_rule_with_metadata` + interceptor in new development instead of the `post_delete_branch_rule` interceptor. + When both interceptors are used, this `post_delete_branch_rule_with_metadata` interceptor runs after the + `post_delete_branch_rule` interceptor. The (possibly modified) response returned by + `post_delete_branch_rule` will be passed to + `post_delete_branch_rule_with_metadata`. """ return response, metadata - def pre_list_repositories( + def pre_delete_hook( self, - request: secure_source_manager.ListRepositoriesRequest, + request: secure_source_manager.DeleteHookRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.ListRepositoriesRequest, - Sequence[Tuple[str, Union[str, bytes]]], + secure_source_manager.DeleteHookRequest, Sequence[Tuple[str, Union[str, bytes]]] ]: - """Pre-rpc interceptor for list_repositories + """Pre-rpc interceptor for delete_hook Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_list_repositories( - self, response: secure_source_manager.ListRepositoriesResponse - ) -> secure_source_manager.ListRepositoriesResponse: - """Post-rpc interceptor for list_repositories + def post_delete_hook( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_hook - DEPRECATED. Please use the `post_list_repositories_with_metadata` + DEPRECATED. Please use the `post_delete_hook_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_list_repositories` interceptor runs - before the `post_list_repositories_with_metadata` interceptor. + it is returned to user code. This `post_delete_hook` interceptor runs + before the `post_delete_hook_with_metadata` interceptor. """ return response - def post_list_repositories_with_metadata( + def post_delete_hook_with_metadata( self, - response: secure_source_manager.ListRepositoriesResponse, + response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - secure_source_manager.ListRepositoriesResponse, - Sequence[Tuple[str, Union[str, bytes]]], - ]: - """Post-rpc interceptor for list_repositories + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_hook Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_list_repositories_with_metadata` - interceptor in new development instead of the `post_list_repositories` interceptor. - When both interceptors are used, this `post_list_repositories_with_metadata` interceptor runs after the - `post_list_repositories` interceptor. The (possibly modified) response returned by - `post_list_repositories` will be passed to - `post_list_repositories_with_metadata`. + We recommend only using this `post_delete_hook_with_metadata` + interceptor in new development instead of the `post_delete_hook` interceptor. + When both interceptors are used, this `post_delete_hook_with_metadata` interceptor runs after the + `post_delete_hook` interceptor. The (possibly modified) response returned by + `post_delete_hook` will be passed to + `post_delete_hook_with_metadata`. """ return response, metadata - def pre_set_iam_policy_repo( + def pre_delete_instance( self, - request: iam_policy_pb2.SetIamPolicyRequest, + request: secure_source_manager.DeleteInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + secure_source_manager.DeleteInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for set_iam_policy_repo + """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_set_iam_policy_repo( - self, response: policy_pb2.Policy - ) -> policy_pb2.Policy: - """Post-rpc interceptor for set_iam_policy_repo + def post_delete_instance( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_instance - DEPRECATED. Please use the `post_set_iam_policy_repo_with_metadata` + DEPRECATED. Please use the `post_delete_instance_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_set_iam_policy_repo` interceptor runs - before the `post_set_iam_policy_repo_with_metadata` interceptor. + it is returned to user code. This `post_delete_instance` interceptor runs + before the `post_delete_instance_with_metadata` interceptor. """ return response - def post_set_iam_policy_repo_with_metadata( + def post_delete_instance_with_metadata( self, - response: policy_pb2.Policy, + response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[policy_pb2.Policy, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for set_iam_policy_repo + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_instance Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_set_iam_policy_repo_with_metadata` - interceptor in new development instead of the `post_set_iam_policy_repo` interceptor. - When both interceptors are used, this `post_set_iam_policy_repo_with_metadata` interceptor runs after the - `post_set_iam_policy_repo` interceptor. The (possibly modified) response returned by - `post_set_iam_policy_repo` will be passed to - `post_set_iam_policy_repo_with_metadata`. + We recommend only using this `post_delete_instance_with_metadata` + interceptor in new development instead of the `post_delete_instance` interceptor. + When both interceptors are used, this `post_delete_instance_with_metadata` interceptor runs after the + `post_delete_instance` interceptor. The (possibly modified) response returned by + `post_delete_instance` will be passed to + `post_delete_instance_with_metadata`. """ return response, metadata - def pre_test_iam_permissions_repo( + def pre_delete_issue( self, - request: iam_policy_pb2.TestIamPermissionsRequest, + request: secure_source_manager.DeleteIssueRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - iam_policy_pb2.TestIamPermissionsRequest, + secure_source_manager.DeleteIssueRequest, Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for test_iam_permissions_repo + """Pre-rpc interceptor for delete_issue Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_test_iam_permissions_repo( - self, response: iam_policy_pb2.TestIamPermissionsResponse - ) -> iam_policy_pb2.TestIamPermissionsResponse: - """Post-rpc interceptor for test_iam_permissions_repo + def post_delete_issue( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_issue - DEPRECATED. Please use the `post_test_iam_permissions_repo_with_metadata` + DEPRECATED. Please use the `post_delete_issue_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_test_iam_permissions_repo` interceptor runs - before the `post_test_iam_permissions_repo_with_metadata` interceptor. + it is returned to user code. This `post_delete_issue` interceptor runs + before the `post_delete_issue_with_metadata` interceptor. """ return response - def post_test_iam_permissions_repo_with_metadata( + def post_delete_issue_with_metadata( self, - response: iam_policy_pb2.TestIamPermissionsResponse, + response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - iam_policy_pb2.TestIamPermissionsResponse, - Sequence[Tuple[str, Union[str, bytes]]], - ]: - """Post-rpc interceptor for test_iam_permissions_repo + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_issue Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_test_iam_permissions_repo_with_metadata` - interceptor in new development instead of the `post_test_iam_permissions_repo` interceptor. - When both interceptors are used, this `post_test_iam_permissions_repo_with_metadata` interceptor runs after the - `post_test_iam_permissions_repo` interceptor. The (possibly modified) response returned by - `post_test_iam_permissions_repo` will be passed to - `post_test_iam_permissions_repo_with_metadata`. + We recommend only using this `post_delete_issue_with_metadata` + interceptor in new development instead of the `post_delete_issue` interceptor. + When both interceptors are used, this `post_delete_issue_with_metadata` interceptor runs after the + `post_delete_issue` interceptor. The (possibly modified) response returned by + `post_delete_issue` will be passed to + `post_delete_issue_with_metadata`. """ return response, metadata - def pre_update_branch_rule( + def pre_delete_issue_comment( self, - request: secure_source_manager.UpdateBranchRuleRequest, + request: secure_source_manager.DeleteIssueCommentRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - secure_source_manager.UpdateBranchRuleRequest, + secure_source_manager.DeleteIssueCommentRequest, Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for update_branch_rule + """Pre-rpc interceptor for delete_issue_comment Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_update_branch_rule( + def post_delete_issue_comment( self, response: operations_pb2.Operation ) -> operations_pb2.Operation: - """Post-rpc interceptor for update_branch_rule + """Post-rpc interceptor for delete_issue_comment - DEPRECATED. Please use the `post_update_branch_rule_with_metadata` + DEPRECATED. Please use the `post_delete_issue_comment_with_metadata` interceptor instead. Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. This `post_update_branch_rule` interceptor runs - before the `post_update_branch_rule_with_metadata` interceptor. + it is returned to user code. This `post_delete_issue_comment` interceptor runs + before the `post_delete_issue_comment_with_metadata` interceptor. """ return response - def post_update_branch_rule_with_metadata( + def post_delete_issue_comment_with_metadata( self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_branch_rule + """Post-rpc interceptor for delete_issue_comment Override in a subclass to read or manipulate the response or metadata after it is returned by the SecureSourceManager server but before it is returned to user code. - We recommend only using this `post_update_branch_rule_with_metadata` - interceptor in new development instead of the `post_update_branch_rule` interceptor. - When both interceptors are used, this `post_update_branch_rule_with_metadata` interceptor runs after the - `post_update_branch_rule` interceptor. The (possibly modified) response returned by - `post_update_branch_rule` will be passed to - `post_update_branch_rule_with_metadata`. + We recommend only using this `post_delete_issue_comment_with_metadata` + interceptor in new development instead of the `post_delete_issue_comment` interceptor. + When both interceptors are used, this `post_delete_issue_comment_with_metadata` interceptor runs after the + `post_delete_issue_comment` interceptor. The (possibly modified) response returned by + `post_delete_issue_comment` will be passed to + `post_delete_issue_comment_with_metadata`. """ return response, metadata - def pre_get_location( + def pre_delete_pull_request_comment( self, - request: locations_pb2.GetLocationRequest, + request: secure_source_manager.DeletePullRequestCommentRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + secure_source_manager.DeletePullRequestCommentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for get_location + """Pre-rpc interceptor for delete_pull_request_comment Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location + def post_delete_pull_request_comment( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_pull_request_comment - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_delete_pull_request_comment_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. + it is returned to user code. This `post_delete_pull_request_comment` interceptor runs + before the `post_delete_pull_request_comment_with_metadata` interceptor. """ return response - def pre_list_locations( + def post_delete_pull_request_comment_with_metadata( self, - request: locations_pb2.ListLocationsRequest, + response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]], - ) -> Tuple[ - locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] - ]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecureSourceManager server. - """ - return request, metadata + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_pull_request_comment - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. - Override in a subclass to manipulate the response - after it is returned by the SecureSourceManager server but before - it is returned to user code. + We recommend only using this `post_delete_pull_request_comment_with_metadata` + interceptor in new development instead of the `post_delete_pull_request_comment` interceptor. + When both interceptors are used, this `post_delete_pull_request_comment_with_metadata` interceptor runs after the + `post_delete_pull_request_comment` interceptor. The (possibly modified) response returned by + `post_delete_pull_request_comment` will be passed to + `post_delete_pull_request_comment_with_metadata`. """ - return response + return response, metadata - def pre_get_iam_policy( + def pre_delete_repository( self, - request: iam_policy_pb2.GetIamPolicyRequest, + request: secure_source_manager.DeleteRepositoryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + secure_source_manager.DeleteRepositoryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for get_iam_policy + """Pre-rpc interceptor for delete_repository Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: - """Post-rpc interceptor for get_iam_policy + def post_delete_repository( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_repository - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_delete_repository_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. + it is returned to user code. This `post_delete_repository` interceptor runs + before the `post_delete_repository_with_metadata` interceptor. """ return response - def pre_set_iam_policy( + def post_delete_repository_with_metadata( self, - request: iam_policy_pb2.SetIamPolicyRequest, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_repository + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_delete_repository_with_metadata` + interceptor in new development instead of the `post_delete_repository` interceptor. + When both interceptors are used, this `post_delete_repository_with_metadata` interceptor runs after the + `post_delete_repository` interceptor. The (possibly modified) response returned by + `post_delete_repository` will be passed to + `post_delete_repository_with_metadata`. + """ + return response, metadata + + def pre_fetch_blob( + self, + request: secure_source_manager.FetchBlobRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + secure_source_manager.FetchBlobRequest, Sequence[Tuple[str, Union[str, bytes]]] ]: - """Pre-rpc interceptor for set_iam_policy + """Pre-rpc interceptor for fetch_blob Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: - """Post-rpc interceptor for set_iam_policy + def post_fetch_blob( + self, response: secure_source_manager.FetchBlobResponse + ) -> secure_source_manager.FetchBlobResponse: + """Post-rpc interceptor for fetch_blob - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_fetch_blob_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. + it is returned to user code. This `post_fetch_blob` interceptor runs + before the `post_fetch_blob_with_metadata` interceptor. """ return response - def pre_test_iam_permissions( + def post_fetch_blob_with_metadata( self, - request: iam_policy_pb2.TestIamPermissionsRequest, + response: secure_source_manager.FetchBlobResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - iam_policy_pb2.TestIamPermissionsRequest, - Sequence[Tuple[str, Union[str, bytes]]], + secure_source_manager.FetchBlobResponse, Sequence[Tuple[str, Union[str, bytes]]] ]: - """Pre-rpc interceptor for test_iam_permissions + """Post-rpc interceptor for fetch_blob - Override in a subclass to manipulate the request or metadata - before they are sent to the SecureSourceManager server. - """ - return request, metadata + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. - def post_test_iam_permissions( - self, response: iam_policy_pb2.TestIamPermissionsResponse - ) -> iam_policy_pb2.TestIamPermissionsResponse: - """Post-rpc interceptor for test_iam_permissions + We recommend only using this `post_fetch_blob_with_metadata` + interceptor in new development instead of the `post_fetch_blob` interceptor. + When both interceptors are used, this `post_fetch_blob_with_metadata` interceptor runs after the + `post_fetch_blob` interceptor. The (possibly modified) response returned by + `post_fetch_blob` will be passed to + `post_fetch_blob_with_metadata`. + """ + return response, metadata - Override in a subclass to manipulate the response + def pre_fetch_tree( + self, + request: secure_source_manager.FetchTreeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.FetchTreeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for fetch_tree + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_fetch_tree( + self, response: secure_source_manager.FetchTreeResponse + ) -> secure_source_manager.FetchTreeResponse: + """Post-rpc interceptor for fetch_tree + + DEPRECATED. Please use the `post_fetch_tree_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. + it is returned to user code. This `post_fetch_tree` interceptor runs + before the `post_fetch_tree_with_metadata` interceptor. """ return response - def pre_cancel_operation( + def post_fetch_tree_with_metadata( self, - request: operations_pb2.CancelOperationRequest, + response: secure_source_manager.FetchTreeResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + secure_source_manager.FetchTreeResponse, Sequence[Tuple[str, Union[str, bytes]]] ]: - """Pre-rpc interceptor for cancel_operation + """Post-rpc interceptor for fetch_tree + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_fetch_tree_with_metadata` + interceptor in new development instead of the `post_fetch_tree` interceptor. + When both interceptors are used, this `post_fetch_tree_with_metadata` interceptor runs after the + `post_fetch_tree` interceptor. The (possibly modified) response returned by + `post_fetch_tree` will be passed to + `post_fetch_tree_with_metadata`. + """ + return response, metadata + + def pre_get_branch_rule( + self, + request: secure_source_manager.GetBranchRuleRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.GetBranchRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for get_branch_rule Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_cancel_operation(self, response: None) -> None: - """Post-rpc interceptor for cancel_operation + def post_get_branch_rule( + self, response: secure_source_manager.BranchRule + ) -> secure_source_manager.BranchRule: + """Post-rpc interceptor for get_branch_rule - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_get_branch_rule_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. + it is returned to user code. This `post_get_branch_rule` interceptor runs + before the `post_get_branch_rule_with_metadata` interceptor. """ return response - def pre_delete_operation( + def post_get_branch_rule_with_metadata( self, - request: operations_pb2.DeleteOperationRequest, + response: secure_source_manager.BranchRule, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + secure_source_manager.BranchRule, Sequence[Tuple[str, Union[str, bytes]]] ]: - """Pre-rpc interceptor for delete_operation + """Post-rpc interceptor for get_branch_rule + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_get_branch_rule_with_metadata` + interceptor in new development instead of the `post_get_branch_rule` interceptor. + When both interceptors are used, this `post_get_branch_rule_with_metadata` interceptor runs after the + `post_get_branch_rule` interceptor. The (possibly modified) response returned by + `post_get_branch_rule` will be passed to + `post_get_branch_rule_with_metadata`. + """ + return response, metadata + + def pre_get_hook( + self, + request: secure_source_manager.GetHookRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.GetHookRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for get_hook Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_delete_operation(self, response: None) -> None: - """Post-rpc interceptor for delete_operation + def post_get_hook( + self, response: secure_source_manager.Hook + ) -> secure_source_manager.Hook: + """Post-rpc interceptor for get_hook - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_get_hook_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. + it is returned to user code. This `post_get_hook` interceptor runs + before the `post_get_hook_with_metadata` interceptor. """ return response - def pre_get_operation( + def post_get_hook_with_metadata( self, - request: operations_pb2.GetOperationRequest, + response: secure_source_manager.Hook, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[secure_source_manager.Hook, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_hook + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_get_hook_with_metadata` + interceptor in new development instead of the `post_get_hook` interceptor. + When both interceptors are used, this `post_get_hook_with_metadata` interceptor runs after the + `post_get_hook` interceptor. The (possibly modified) response returned by + `post_get_hook` will be passed to + `post_get_hook_with_metadata`. + """ + return response, metadata + + def pre_get_iam_policy_repo( + self, + request: iam_policy_pb2.GetIamPolicyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] ]: - """Pre-rpc interceptor for get_operation + """Pre-rpc interceptor for get_iam_policy_repo Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_get_operation( - self, response: operations_pb2.Operation - ) -> operations_pb2.Operation: - """Post-rpc interceptor for get_operation + def post_get_iam_policy_repo( + self, response: policy_pb2.Policy + ) -> policy_pb2.Policy: + """Post-rpc interceptor for get_iam_policy_repo - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_get_iam_policy_repo_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. + it is returned to user code. This `post_get_iam_policy_repo` interceptor runs + before the `post_get_iam_policy_repo_with_metadata` interceptor. """ return response - def pre_list_operations( + def post_get_iam_policy_repo_with_metadata( self, - request: operations_pb2.ListOperationsRequest, + response: policy_pb2.Policy, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[policy_pb2.Policy, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_iam_policy_repo + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_get_iam_policy_repo_with_metadata` + interceptor in new development instead of the `post_get_iam_policy_repo` interceptor. + When both interceptors are used, this `post_get_iam_policy_repo_with_metadata` interceptor runs after the + `post_get_iam_policy_repo` interceptor. The (possibly modified) response returned by + `post_get_iam_policy_repo` will be passed to + `post_get_iam_policy_repo_with_metadata`. + """ + return response, metadata + + def pre_get_instance( + self, + request: secure_source_manager.GetInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + secure_source_manager.GetInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for list_operations + """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata before they are sent to the SecureSourceManager server. """ return request, metadata - def post_list_operations( - self, response: operations_pb2.ListOperationsResponse - ) -> operations_pb2.ListOperationsResponse: - """Post-rpc interceptor for list_operations + def post_get_instance( + self, response: secure_source_manager.Instance + ) -> secure_source_manager.Instance: + """Post-rpc interceptor for get_instance - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_get_instance_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the SecureSourceManager server but before - it is returned to user code. + it is returned to user code. This `post_get_instance` interceptor runs + before the `post_get_instance_with_metadata` interceptor. """ return response + def post_get_instance_with_metadata( + self, + response: secure_source_manager.Instance, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[secure_source_manager.Instance, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_instance -@dataclasses.dataclass -class SecureSourceManagerRestStub: - _session: AuthorizedSession - _host: str - _interceptor: SecureSourceManagerRestInterceptor - + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. -class SecureSourceManagerRestTransport(_BaseSecureSourceManagerRestTransport): - """REST backend synchronous transport for SecureSourceManager. + We recommend only using this `post_get_instance_with_metadata` + interceptor in new development instead of the `post_get_instance` interceptor. + When both interceptors are used, this `post_get_instance_with_metadata` interceptor runs after the + `post_get_instance` interceptor. The (possibly modified) response returned by + `post_get_instance` will be passed to + `post_get_instance_with_metadata`. + """ + return response, metadata - Secure Source Manager API + def pre_get_issue( + self, + request: secure_source_manager.GetIssueRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.GetIssueRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for get_issue - Access Secure Source Manager instances, resources, and repositories. + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata - This API is split across two servers: the Control Plane and the Data - Plane. + def post_get_issue( + self, response: secure_source_manager.Issue + ) -> secure_source_manager.Issue: + """Post-rpc interceptor for get_issue - Data Plane endpoints are hosted directly by your Secure Source - Manager instance, so you must connect to your instance's API - hostname to access them. The API hostname looks like the following: + DEPRECATED. Please use the `post_get_issue_with_metadata` + interceptor instead. - :: + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_get_issue` interceptor runs + before the `post_get_issue_with_metadata` interceptor. + """ + return response - https://[instance-id]-[project-number]-api.[location].sourcemanager.dev + def post_get_issue_with_metadata( + self, + response: secure_source_manager.Issue, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[secure_source_manager.Issue, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_issue - For example, + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. - :: + We recommend only using this `post_get_issue_with_metadata` + interceptor in new development instead of the `post_get_issue` interceptor. + When both interceptors are used, this `post_get_issue_with_metadata` interceptor runs after the + `post_get_issue` interceptor. The (possibly modified) response returned by + `post_get_issue` will be passed to + `post_get_issue_with_metadata`. + """ + return response, metadata - https://my-instance-702770452863-api.us-central1.sourcemanager.dev + def pre_get_issue_comment( + self, + request: secure_source_manager.GetIssueCommentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.GetIssueCommentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for get_issue_comment - Data Plane endpoints are denoted with **Host: Data Plane**. + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata - All other endpoints are found in the normal Cloud API location, - namely, ``securcesourcemanager.googleapis.com``. + def post_get_issue_comment( + self, response: secure_source_manager.IssueComment + ) -> secure_source_manager.IssueComment: + """Post-rpc interceptor for get_issue_comment - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. + DEPRECATED. Please use the `post_get_issue_comment_with_metadata` + interceptor instead. - It sends JSON representations of protocol buffers over HTTP/1.1 - """ + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_get_issue_comment` interceptor runs + before the `post_get_issue_comment_with_metadata` interceptor. + """ + return response - def __init__( + def post_get_issue_comment_with_metadata( self, - *, - host: str = "securesourcemanager.googleapis.com", - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - url_scheme: str = "https", - interceptor: Optional[SecureSourceManagerRestInterceptor] = None, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. + response: secure_source_manager.IssueComment, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.IssueComment, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Post-rpc interceptor for get_issue_comment - Args: - host (Optional[str]): - The hostname to connect to (default: 'securesourcemanager.googleapis.com'). - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_get_issue_comment_with_metadata` + interceptor in new development instead of the `post_get_issue_comment` interceptor. + When both interceptors are used, this `post_get_issue_comment_with_metadata` interceptor runs after the + `post_get_issue_comment` interceptor. The (possibly modified) response returned by + `post_get_issue_comment` will be passed to + `post_get_issue_comment_with_metadata`. + """ + return response, metadata + + def pre_get_pull_request( + self, + request: secure_source_manager.GetPullRequestRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.GetPullRequestRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for get_pull_request + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_get_pull_request( + self, response: secure_source_manager.PullRequest + ) -> secure_source_manager.PullRequest: + """Post-rpc interceptor for get_pull_request + + DEPRECATED. Please use the `post_get_pull_request_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_get_pull_request` interceptor runs + before the `post_get_pull_request_with_metadata` interceptor. + """ + return response + + def post_get_pull_request_with_metadata( + self, + response: secure_source_manager.PullRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.PullRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Post-rpc interceptor for get_pull_request + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_get_pull_request_with_metadata` + interceptor in new development instead of the `post_get_pull_request` interceptor. + When both interceptors are used, this `post_get_pull_request_with_metadata` interceptor runs after the + `post_get_pull_request` interceptor. The (possibly modified) response returned by + `post_get_pull_request` will be passed to + `post_get_pull_request_with_metadata`. + """ + return response, metadata + + def pre_get_pull_request_comment( + self, + request: secure_source_manager.GetPullRequestCommentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.GetPullRequestCommentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for get_pull_request_comment + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_get_pull_request_comment( + self, response: secure_source_manager.PullRequestComment + ) -> secure_source_manager.PullRequestComment: + """Post-rpc interceptor for get_pull_request_comment + + DEPRECATED. Please use the `post_get_pull_request_comment_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_get_pull_request_comment` interceptor runs + before the `post_get_pull_request_comment_with_metadata` interceptor. + """ + return response + + def post_get_pull_request_comment_with_metadata( + self, + response: secure_source_manager.PullRequestComment, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.PullRequestComment, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for get_pull_request_comment + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_get_pull_request_comment_with_metadata` + interceptor in new development instead of the `post_get_pull_request_comment` interceptor. + When both interceptors are used, this `post_get_pull_request_comment_with_metadata` interceptor runs after the + `post_get_pull_request_comment` interceptor. The (possibly modified) response returned by + `post_get_pull_request_comment` will be passed to + `post_get_pull_request_comment_with_metadata`. + """ + return response, metadata + + def pre_get_repository( + self, + request: secure_source_manager.GetRepositoryRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.GetRepositoryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for get_repository + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_get_repository( + self, response: secure_source_manager.Repository + ) -> secure_source_manager.Repository: + """Post-rpc interceptor for get_repository + + DEPRECATED. Please use the `post_get_repository_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_get_repository` interceptor runs + before the `post_get_repository_with_metadata` interceptor. + """ + return response + + def post_get_repository_with_metadata( + self, + response: secure_source_manager.Repository, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.Repository, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Post-rpc interceptor for get_repository + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_get_repository_with_metadata` + interceptor in new development instead of the `post_get_repository` interceptor. + When both interceptors are used, this `post_get_repository_with_metadata` interceptor runs after the + `post_get_repository` interceptor. The (possibly modified) response returned by + `post_get_repository` will be passed to + `post_get_repository_with_metadata`. + """ + return response, metadata + + def pre_list_branch_rules( + self, + request: secure_source_manager.ListBranchRulesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListBranchRulesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for list_branch_rules + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_list_branch_rules( + self, response: secure_source_manager.ListBranchRulesResponse + ) -> secure_source_manager.ListBranchRulesResponse: + """Post-rpc interceptor for list_branch_rules + + DEPRECATED. Please use the `post_list_branch_rules_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_list_branch_rules` interceptor runs + before the `post_list_branch_rules_with_metadata` interceptor. + """ + return response + + def post_list_branch_rules_with_metadata( + self, + response: secure_source_manager.ListBranchRulesResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListBranchRulesResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_branch_rules + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_list_branch_rules_with_metadata` + interceptor in new development instead of the `post_list_branch_rules` interceptor. + When both interceptors are used, this `post_list_branch_rules_with_metadata` interceptor runs after the + `post_list_branch_rules` interceptor. The (possibly modified) response returned by + `post_list_branch_rules` will be passed to + `post_list_branch_rules_with_metadata`. + """ + return response, metadata + + def pre_list_hooks( + self, + request: secure_source_manager.ListHooksRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListHooksRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for list_hooks + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_list_hooks( + self, response: secure_source_manager.ListHooksResponse + ) -> secure_source_manager.ListHooksResponse: + """Post-rpc interceptor for list_hooks + + DEPRECATED. Please use the `post_list_hooks_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_list_hooks` interceptor runs + before the `post_list_hooks_with_metadata` interceptor. + """ + return response + + def post_list_hooks_with_metadata( + self, + response: secure_source_manager.ListHooksResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListHooksResponse, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Post-rpc interceptor for list_hooks + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_list_hooks_with_metadata` + interceptor in new development instead of the `post_list_hooks` interceptor. + When both interceptors are used, this `post_list_hooks_with_metadata` interceptor runs after the + `post_list_hooks` interceptor. The (possibly modified) response returned by + `post_list_hooks` will be passed to + `post_list_hooks_with_metadata`. + """ + return response, metadata + + def pre_list_instances( + self, + request: secure_source_manager.ListInstancesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListInstancesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for list_instances + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_list_instances( + self, response: secure_source_manager.ListInstancesResponse + ) -> secure_source_manager.ListInstancesResponse: + """Post-rpc interceptor for list_instances + + DEPRECATED. Please use the `post_list_instances_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_list_instances` interceptor runs + before the `post_list_instances_with_metadata` interceptor. + """ + return response + + def post_list_instances_with_metadata( + self, + response: secure_source_manager.ListInstancesResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListInstancesResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_instances + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_list_instances_with_metadata` + interceptor in new development instead of the `post_list_instances` interceptor. + When both interceptors are used, this `post_list_instances_with_metadata` interceptor runs after the + `post_list_instances` interceptor. The (possibly modified) response returned by + `post_list_instances` will be passed to + `post_list_instances_with_metadata`. + """ + return response, metadata + + def pre_list_issue_comments( + self, + request: secure_source_manager.ListIssueCommentsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListIssueCommentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for list_issue_comments + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_list_issue_comments( + self, response: secure_source_manager.ListIssueCommentsResponse + ) -> secure_source_manager.ListIssueCommentsResponse: + """Post-rpc interceptor for list_issue_comments + + DEPRECATED. Please use the `post_list_issue_comments_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_list_issue_comments` interceptor runs + before the `post_list_issue_comments_with_metadata` interceptor. + """ + return response + + def post_list_issue_comments_with_metadata( + self, + response: secure_source_manager.ListIssueCommentsResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListIssueCommentsResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_issue_comments + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_list_issue_comments_with_metadata` + interceptor in new development instead of the `post_list_issue_comments` interceptor. + When both interceptors are used, this `post_list_issue_comments_with_metadata` interceptor runs after the + `post_list_issue_comments` interceptor. The (possibly modified) response returned by + `post_list_issue_comments` will be passed to + `post_list_issue_comments_with_metadata`. + """ + return response, metadata + + def pre_list_issues( + self, + request: secure_source_manager.ListIssuesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListIssuesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for list_issues + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_list_issues( + self, response: secure_source_manager.ListIssuesResponse + ) -> secure_source_manager.ListIssuesResponse: + """Post-rpc interceptor for list_issues + + DEPRECATED. Please use the `post_list_issues_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_list_issues` interceptor runs + before the `post_list_issues_with_metadata` interceptor. + """ + return response + + def post_list_issues_with_metadata( + self, + response: secure_source_manager.ListIssuesResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListIssuesResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_issues + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_list_issues_with_metadata` + interceptor in new development instead of the `post_list_issues` interceptor. + When both interceptors are used, this `post_list_issues_with_metadata` interceptor runs after the + `post_list_issues` interceptor. The (possibly modified) response returned by + `post_list_issues` will be passed to + `post_list_issues_with_metadata`. + """ + return response, metadata + + def pre_list_pull_request_comments( + self, + request: secure_source_manager.ListPullRequestCommentsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListPullRequestCommentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for list_pull_request_comments + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_list_pull_request_comments( + self, response: secure_source_manager.ListPullRequestCommentsResponse + ) -> secure_source_manager.ListPullRequestCommentsResponse: + """Post-rpc interceptor for list_pull_request_comments + + DEPRECATED. Please use the `post_list_pull_request_comments_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_list_pull_request_comments` interceptor runs + before the `post_list_pull_request_comments_with_metadata` interceptor. + """ + return response + + def post_list_pull_request_comments_with_metadata( + self, + response: secure_source_manager.ListPullRequestCommentsResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListPullRequestCommentsResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_pull_request_comments + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_list_pull_request_comments_with_metadata` + interceptor in new development instead of the `post_list_pull_request_comments` interceptor. + When both interceptors are used, this `post_list_pull_request_comments_with_metadata` interceptor runs after the + `post_list_pull_request_comments` interceptor. The (possibly modified) response returned by + `post_list_pull_request_comments` will be passed to + `post_list_pull_request_comments_with_metadata`. + """ + return response, metadata + + def pre_list_pull_request_file_diffs( + self, + request: secure_source_manager.ListPullRequestFileDiffsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListPullRequestFileDiffsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for list_pull_request_file_diffs + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_list_pull_request_file_diffs( + self, response: secure_source_manager.ListPullRequestFileDiffsResponse + ) -> secure_source_manager.ListPullRequestFileDiffsResponse: + """Post-rpc interceptor for list_pull_request_file_diffs + + DEPRECATED. Please use the `post_list_pull_request_file_diffs_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_list_pull_request_file_diffs` interceptor runs + before the `post_list_pull_request_file_diffs_with_metadata` interceptor. + """ + return response + + def post_list_pull_request_file_diffs_with_metadata( + self, + response: secure_source_manager.ListPullRequestFileDiffsResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListPullRequestFileDiffsResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_pull_request_file_diffs + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_list_pull_request_file_diffs_with_metadata` + interceptor in new development instead of the `post_list_pull_request_file_diffs` interceptor. + When both interceptors are used, this `post_list_pull_request_file_diffs_with_metadata` interceptor runs after the + `post_list_pull_request_file_diffs` interceptor. The (possibly modified) response returned by + `post_list_pull_request_file_diffs` will be passed to + `post_list_pull_request_file_diffs_with_metadata`. + """ + return response, metadata + + def pre_list_pull_requests( + self, + request: secure_source_manager.ListPullRequestsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListPullRequestsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for list_pull_requests + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_list_pull_requests( + self, response: secure_source_manager.ListPullRequestsResponse + ) -> secure_source_manager.ListPullRequestsResponse: + """Post-rpc interceptor for list_pull_requests + + DEPRECATED. Please use the `post_list_pull_requests_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_list_pull_requests` interceptor runs + before the `post_list_pull_requests_with_metadata` interceptor. + """ + return response + + def post_list_pull_requests_with_metadata( + self, + response: secure_source_manager.ListPullRequestsResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListPullRequestsResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_pull_requests + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_list_pull_requests_with_metadata` + interceptor in new development instead of the `post_list_pull_requests` interceptor. + When both interceptors are used, this `post_list_pull_requests_with_metadata` interceptor runs after the + `post_list_pull_requests` interceptor. The (possibly modified) response returned by + `post_list_pull_requests` will be passed to + `post_list_pull_requests_with_metadata`. + """ + return response, metadata + + def pre_list_repositories( + self, + request: secure_source_manager.ListRepositoriesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListRepositoriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for list_repositories + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_list_repositories( + self, response: secure_source_manager.ListRepositoriesResponse + ) -> secure_source_manager.ListRepositoriesResponse: + """Post-rpc interceptor for list_repositories + + DEPRECATED. Please use the `post_list_repositories_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_list_repositories` interceptor runs + before the `post_list_repositories_with_metadata` interceptor. + """ + return response + + def post_list_repositories_with_metadata( + self, + response: secure_source_manager.ListRepositoriesResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ListRepositoriesResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_repositories + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_list_repositories_with_metadata` + interceptor in new development instead of the `post_list_repositories` interceptor. + When both interceptors are used, this `post_list_repositories_with_metadata` interceptor runs after the + `post_list_repositories` interceptor. The (possibly modified) response returned by + `post_list_repositories` will be passed to + `post_list_repositories_with_metadata`. + """ + return response, metadata + + def pre_merge_pull_request( + self, + request: secure_source_manager.MergePullRequestRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.MergePullRequestRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for merge_pull_request + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_merge_pull_request( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for merge_pull_request + + DEPRECATED. Please use the `post_merge_pull_request_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_merge_pull_request` interceptor runs + before the `post_merge_pull_request_with_metadata` interceptor. + """ + return response + + def post_merge_pull_request_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for merge_pull_request + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_merge_pull_request_with_metadata` + interceptor in new development instead of the `post_merge_pull_request` interceptor. + When both interceptors are used, this `post_merge_pull_request_with_metadata` interceptor runs after the + `post_merge_pull_request` interceptor. The (possibly modified) response returned by + `post_merge_pull_request` will be passed to + `post_merge_pull_request_with_metadata`. + """ + return response, metadata + + def pre_open_issue( + self, + request: secure_source_manager.OpenIssueRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.OpenIssueRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for open_issue + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_open_issue( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for open_issue + + DEPRECATED. Please use the `post_open_issue_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_open_issue` interceptor runs + before the `post_open_issue_with_metadata` interceptor. + """ + return response + + def post_open_issue_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for open_issue + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_open_issue_with_metadata` + interceptor in new development instead of the `post_open_issue` interceptor. + When both interceptors are used, this `post_open_issue_with_metadata` interceptor runs after the + `post_open_issue` interceptor. The (possibly modified) response returned by + `post_open_issue` will be passed to + `post_open_issue_with_metadata`. + """ + return response, metadata + + def pre_open_pull_request( + self, + request: secure_source_manager.OpenPullRequestRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.OpenPullRequestRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for open_pull_request + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_open_pull_request( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for open_pull_request + + DEPRECATED. Please use the `post_open_pull_request_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_open_pull_request` interceptor runs + before the `post_open_pull_request_with_metadata` interceptor. + """ + return response + + def post_open_pull_request_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for open_pull_request + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_open_pull_request_with_metadata` + interceptor in new development instead of the `post_open_pull_request` interceptor. + When both interceptors are used, this `post_open_pull_request_with_metadata` interceptor runs after the + `post_open_pull_request` interceptor. The (possibly modified) response returned by + `post_open_pull_request` will be passed to + `post_open_pull_request_with_metadata`. + """ + return response, metadata + + def pre_resolve_pull_request_comments( + self, + request: secure_source_manager.ResolvePullRequestCommentsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.ResolvePullRequestCommentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for resolve_pull_request_comments + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_resolve_pull_request_comments( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for resolve_pull_request_comments + + DEPRECATED. Please use the `post_resolve_pull_request_comments_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_resolve_pull_request_comments` interceptor runs + before the `post_resolve_pull_request_comments_with_metadata` interceptor. + """ + return response + + def post_resolve_pull_request_comments_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for resolve_pull_request_comments + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_resolve_pull_request_comments_with_metadata` + interceptor in new development instead of the `post_resolve_pull_request_comments` interceptor. + When both interceptors are used, this `post_resolve_pull_request_comments_with_metadata` interceptor runs after the + `post_resolve_pull_request_comments` interceptor. The (possibly modified) response returned by + `post_resolve_pull_request_comments` will be passed to + `post_resolve_pull_request_comments_with_metadata`. + """ + return response, metadata + + def pre_set_iam_policy_repo( + self, + request: iam_policy_pb2.SetIamPolicyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for set_iam_policy_repo + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_set_iam_policy_repo( + self, response: policy_pb2.Policy + ) -> policy_pb2.Policy: + """Post-rpc interceptor for set_iam_policy_repo + + DEPRECATED. Please use the `post_set_iam_policy_repo_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_set_iam_policy_repo` interceptor runs + before the `post_set_iam_policy_repo_with_metadata` interceptor. + """ + return response + + def post_set_iam_policy_repo_with_metadata( + self, + response: policy_pb2.Policy, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[policy_pb2.Policy, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for set_iam_policy_repo + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_set_iam_policy_repo_with_metadata` + interceptor in new development instead of the `post_set_iam_policy_repo` interceptor. + When both interceptors are used, this `post_set_iam_policy_repo_with_metadata` interceptor runs after the + `post_set_iam_policy_repo` interceptor. The (possibly modified) response returned by + `post_set_iam_policy_repo` will be passed to + `post_set_iam_policy_repo_with_metadata`. + """ + return response, metadata + + def pre_test_iam_permissions_repo( + self, + request: iam_policy_pb2.TestIamPermissionsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for test_iam_permissions_repo + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_test_iam_permissions_repo( + self, response: iam_policy_pb2.TestIamPermissionsResponse + ) -> iam_policy_pb2.TestIamPermissionsResponse: + """Post-rpc interceptor for test_iam_permissions_repo + + DEPRECATED. Please use the `post_test_iam_permissions_repo_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_test_iam_permissions_repo` interceptor runs + before the `post_test_iam_permissions_repo_with_metadata` interceptor. + """ + return response + + def post_test_iam_permissions_repo_with_metadata( + self, + response: iam_policy_pb2.TestIamPermissionsResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for test_iam_permissions_repo + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_test_iam_permissions_repo_with_metadata` + interceptor in new development instead of the `post_test_iam_permissions_repo` interceptor. + When both interceptors are used, this `post_test_iam_permissions_repo_with_metadata` interceptor runs after the + `post_test_iam_permissions_repo` interceptor. The (possibly modified) response returned by + `post_test_iam_permissions_repo` will be passed to + `post_test_iam_permissions_repo_with_metadata`. + """ + return response, metadata + + def pre_unresolve_pull_request_comments( + self, + request: secure_source_manager.UnresolvePullRequestCommentsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.UnresolvePullRequestCommentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for unresolve_pull_request_comments + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_unresolve_pull_request_comments( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for unresolve_pull_request_comments + + DEPRECATED. Please use the `post_unresolve_pull_request_comments_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_unresolve_pull_request_comments` interceptor runs + before the `post_unresolve_pull_request_comments_with_metadata` interceptor. + """ + return response + + def post_unresolve_pull_request_comments_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for unresolve_pull_request_comments + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_unresolve_pull_request_comments_with_metadata` + interceptor in new development instead of the `post_unresolve_pull_request_comments` interceptor. + When both interceptors are used, this `post_unresolve_pull_request_comments_with_metadata` interceptor runs after the + `post_unresolve_pull_request_comments` interceptor. The (possibly modified) response returned by + `post_unresolve_pull_request_comments` will be passed to + `post_unresolve_pull_request_comments_with_metadata`. + """ + return response, metadata + + def pre_update_branch_rule( + self, + request: secure_source_manager.UpdateBranchRuleRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.UpdateBranchRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for update_branch_rule + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_update_branch_rule( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for update_branch_rule + + DEPRECATED. Please use the `post_update_branch_rule_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_update_branch_rule` interceptor runs + before the `post_update_branch_rule_with_metadata` interceptor. + """ + return response + + def post_update_branch_rule_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_branch_rule + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_update_branch_rule_with_metadata` + interceptor in new development instead of the `post_update_branch_rule` interceptor. + When both interceptors are used, this `post_update_branch_rule_with_metadata` interceptor runs after the + `post_update_branch_rule` interceptor. The (possibly modified) response returned by + `post_update_branch_rule` will be passed to + `post_update_branch_rule_with_metadata`. + """ + return response, metadata + + def pre_update_hook( + self, + request: secure_source_manager.UpdateHookRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.UpdateHookRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for update_hook + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_update_hook( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for update_hook + + DEPRECATED. Please use the `post_update_hook_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_update_hook` interceptor runs + before the `post_update_hook_with_metadata` interceptor. + """ + return response + + def post_update_hook_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_hook + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_update_hook_with_metadata` + interceptor in new development instead of the `post_update_hook` interceptor. + When both interceptors are used, this `post_update_hook_with_metadata` interceptor runs after the + `post_update_hook` interceptor. The (possibly modified) response returned by + `post_update_hook` will be passed to + `post_update_hook_with_metadata`. + """ + return response, metadata + + def pre_update_issue( + self, + request: secure_source_manager.UpdateIssueRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.UpdateIssueRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for update_issue + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_update_issue( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for update_issue + + DEPRECATED. Please use the `post_update_issue_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_update_issue` interceptor runs + before the `post_update_issue_with_metadata` interceptor. + """ + return response + + def post_update_issue_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_issue + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_update_issue_with_metadata` + interceptor in new development instead of the `post_update_issue` interceptor. + When both interceptors are used, this `post_update_issue_with_metadata` interceptor runs after the + `post_update_issue` interceptor. The (possibly modified) response returned by + `post_update_issue` will be passed to + `post_update_issue_with_metadata`. + """ + return response, metadata + + def pre_update_issue_comment( + self, + request: secure_source_manager.UpdateIssueCommentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.UpdateIssueCommentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for update_issue_comment + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_update_issue_comment( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for update_issue_comment + + DEPRECATED. Please use the `post_update_issue_comment_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_update_issue_comment` interceptor runs + before the `post_update_issue_comment_with_metadata` interceptor. + """ + return response + + def post_update_issue_comment_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_issue_comment + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_update_issue_comment_with_metadata` + interceptor in new development instead of the `post_update_issue_comment` interceptor. + When both interceptors are used, this `post_update_issue_comment_with_metadata` interceptor runs after the + `post_update_issue_comment` interceptor. The (possibly modified) response returned by + `post_update_issue_comment` will be passed to + `post_update_issue_comment_with_metadata`. + """ + return response, metadata + + def pre_update_pull_request( + self, + request: secure_source_manager.UpdatePullRequestRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.UpdatePullRequestRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for update_pull_request + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_update_pull_request( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for update_pull_request + + DEPRECATED. Please use the `post_update_pull_request_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_update_pull_request` interceptor runs + before the `post_update_pull_request_with_metadata` interceptor. + """ + return response + + def post_update_pull_request_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_pull_request + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_update_pull_request_with_metadata` + interceptor in new development instead of the `post_update_pull_request` interceptor. + When both interceptors are used, this `post_update_pull_request_with_metadata` interceptor runs after the + `post_update_pull_request` interceptor. The (possibly modified) response returned by + `post_update_pull_request` will be passed to + `post_update_pull_request_with_metadata`. + """ + return response, metadata + + def pre_update_pull_request_comment( + self, + request: secure_source_manager.UpdatePullRequestCommentRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.UpdatePullRequestCommentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for update_pull_request_comment + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_update_pull_request_comment( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for update_pull_request_comment + + DEPRECATED. Please use the `post_update_pull_request_comment_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_update_pull_request_comment` interceptor runs + before the `post_update_pull_request_comment_with_metadata` interceptor. + """ + return response + + def post_update_pull_request_comment_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_pull_request_comment + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_update_pull_request_comment_with_metadata` + interceptor in new development instead of the `post_update_pull_request_comment` interceptor. + When both interceptors are used, this `post_update_pull_request_comment_with_metadata` interceptor runs after the + `post_update_pull_request_comment` interceptor. The (possibly modified) response returned by + `post_update_pull_request_comment` will be passed to + `post_update_pull_request_comment_with_metadata`. + """ + return response, metadata + + def pre_update_repository( + self, + request: secure_source_manager.UpdateRepositoryRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + secure_source_manager.UpdateRepositoryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for update_repository + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_update_repository( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for update_repository + + DEPRECATED. Please use the `post_update_repository_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. This `post_update_repository` interceptor runs + before the `post_update_repository_with_metadata` interceptor. + """ + return response + + def post_update_repository_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_repository + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the SecureSourceManager server but before it is returned to user code. + + We recommend only using this `post_update_repository_with_metadata` + interceptor in new development instead of the `post_update_repository` interceptor. + When both interceptors are used, this `post_update_repository_with_metadata` interceptor runs after the + `post_update_repository` interceptor. The (possibly modified) response returned by + `post_update_repository` will be passed to + `post_update_repository_with_metadata`. + """ + return response, metadata + + def pre_get_location( + self, + request: locations_pb2.GetLocationRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for get_location + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_get_location( + self, response: locations_pb2.Location + ) -> locations_pb2.Location: + """Post-rpc interceptor for get_location + + Override in a subclass to manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. + """ + return response + + def pre_list_locations( + self, + request: locations_pb2.ListLocationsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for list_locations + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_list_locations( + self, response: locations_pb2.ListLocationsResponse + ) -> locations_pb2.ListLocationsResponse: + """Post-rpc interceptor for list_locations + + Override in a subclass to manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. + """ + return response + + def pre_get_iam_policy( + self, + request: iam_policy_pb2.GetIamPolicyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for get_iam_policy + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: + """Post-rpc interceptor for get_iam_policy + + Override in a subclass to manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. + """ + return response + + def pre_set_iam_policy( + self, + request: iam_policy_pb2.SetIamPolicyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for set_iam_policy + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: + """Post-rpc interceptor for set_iam_policy + + Override in a subclass to manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. + """ + return response + + def pre_test_iam_permissions( + self, + request: iam_policy_pb2.TestIamPermissionsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for test_iam_permissions + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_test_iam_permissions( + self, response: iam_policy_pb2.TestIamPermissionsResponse + ) -> iam_policy_pb2.TestIamPermissionsResponse: + """Post-rpc interceptor for test_iam_permissions + + Override in a subclass to manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. + """ + return response + + def pre_cancel_operation( + self, + request: operations_pb2.CancelOperationRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for cancel_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_cancel_operation(self, response: None) -> None: + """Post-rpc interceptor for cancel_operation + + Override in a subclass to manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. + """ + return response + + def pre_delete_operation( + self, + request: operations_pb2.DeleteOperationRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for delete_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_delete_operation(self, response: None) -> None: + """Post-rpc interceptor for delete_operation + + Override in a subclass to manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. + """ + return response + + def pre_get_operation( + self, + request: operations_pb2.GetOperationRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for get_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_get_operation( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for get_operation + + Override in a subclass to manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. + """ + return response + + def pre_list_operations( + self, + request: operations_pb2.ListOperationsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for list_operations + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecureSourceManager server. + """ + return request, metadata + + def post_list_operations( + self, response: operations_pb2.ListOperationsResponse + ) -> operations_pb2.ListOperationsResponse: + """Post-rpc interceptor for list_operations + + Override in a subclass to manipulate the response + after it is returned by the SecureSourceManager server but before + it is returned to user code. + """ + return response + + +@dataclasses.dataclass +class SecureSourceManagerRestStub: + _session: AuthorizedSession + _host: str + _interceptor: SecureSourceManagerRestInterceptor + + +class SecureSourceManagerRestTransport(_BaseSecureSourceManagerRestTransport): + """REST backend synchronous transport for SecureSourceManager. + + Secure Source Manager API + + Access Secure Source Manager instances, resources, and + repositories. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends JSON representations of protocol buffers over HTTP/1.1 + """ + + def __init__( + self, + *, + host: str = "securesourcemanager.googleapis.com", + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + url_scheme: str = "https", + interceptor: Optional[SecureSourceManagerRestInterceptor] = None, + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to (default: 'securesourcemanager.googleapis.com'). + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client + certificate to configure mutual TLS HTTP channel. It is ignored + if ``channel`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you are developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + url_scheme: the protocol scheme for the API endpoint. Normally + "https", but for testing or local servers, + "http" can be specified. + """ + # Run the base constructor + # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. + # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the + # credentials object + super().__init__( + host=host, + credentials=credentials, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + url_scheme=url_scheme, + api_audience=api_audience, + ) + self._session = AuthorizedSession( + self._credentials, default_host=self.DEFAULT_HOST + ) + self._operations_client: Optional[operations_v1.AbstractOperationsClient] = None + if client_cert_source_for_mtls: + self._session.configure_mtls_channel(client_cert_source_for_mtls) + self._interceptor = interceptor or SecureSourceManagerRestInterceptor() + self._prep_wrapped_messages(client_info) + + @property + def operations_client(self) -> operations_v1.AbstractOperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Only create a new client if we do not already have one. + if self._operations_client is None: + http_options: Dict[str, List[Dict[str, str]]] = { + "google.longrunning.Operations.CancelOperation": [ + { + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/operations/*}:cancel", + "body": "*", + }, + ], + "google.longrunning.Operations.DeleteOperation": [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/operations/*}", + }, + ], + "google.longrunning.Operations.GetOperation": [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/operations/*}", + }, + ], + "google.longrunning.Operations.ListOperations": [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*}/operations", + }, + ], + } + + rest_transport = operations_v1.OperationsRestTransport( + host=self._host, + # use the credentials which are saved + credentials=self._credentials, + scopes=self._scopes, + http_options=http_options, + path_prefix="v1", + ) + + self._operations_client = operations_v1.AbstractOperationsClient( + transport=rest_transport + ) + + # Return the client from cache. + return self._operations_client + + class _BatchCreatePullRequestComments( + _BaseSecureSourceManagerRestTransport._BaseBatchCreatePullRequestComments, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash( + "SecureSourceManagerRestTransport.BatchCreatePullRequestComments" + ) + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: secure_source_manager.BatchCreatePullRequestCommentsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the batch create pull request + comments method over HTTP. + + Args: + request (~.secure_source_manager.BatchCreatePullRequestCommentsRequest): + The request object. The request to batch create pull + request comments. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseBatchCreatePullRequestComments._get_http_options() + ) + + ( + request, + metadata, + ) = self._interceptor.pre_batch_create_pull_request_comments( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseBatchCreatePullRequestComments._get_transcoded_request( + http_options, request + ) + + body = _BaseSecureSourceManagerRestTransport._BaseBatchCreatePullRequestComments._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseBatchCreatePullRequestComments._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.BatchCreatePullRequestComments", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "BatchCreatePullRequestComments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._BatchCreatePullRequestComments._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_batch_create_pull_request_comments(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + ( + resp, + _, + ) = self._interceptor.post_batch_create_pull_request_comments_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.batch_create_pull_request_comments", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "BatchCreatePullRequestComments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CloseIssue( + _BaseSecureSourceManagerRestTransport._BaseCloseIssue, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.CloseIssue") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: secure_source_manager.CloseIssueRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the close issue method over HTTP. + + Args: + request (~.secure_source_manager.CloseIssueRequest): + The request object. The request to close an issue. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseCloseIssue._get_http_options() + ) + + request, metadata = self._interceptor.pre_close_issue(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCloseIssue._get_transcoded_request( + http_options, request + ) + + body = _BaseSecureSourceManagerRestTransport._BaseCloseIssue._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseCloseIssue._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.CloseIssue", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CloseIssue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._CloseIssue._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_close_issue(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_close_issue_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.close_issue", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CloseIssue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ClosePullRequest( + _BaseSecureSourceManagerRestTransport._BaseClosePullRequest, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.ClosePullRequest") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: secure_source_manager.ClosePullRequestRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the close pull request method over HTTP. + + Args: + request (~.secure_source_manager.ClosePullRequestRequest): + The request object. ClosePullRequestRequest is the + request to close a pull request. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseClosePullRequest._get_http_options() + ) + + request, metadata = self._interceptor.pre_close_pull_request( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseClosePullRequest._get_transcoded_request( + http_options, request + ) + + body = _BaseSecureSourceManagerRestTransport._BaseClosePullRequest._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseClosePullRequest._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ClosePullRequest", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ClosePullRequest", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._ClosePullRequest._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_close_pull_request(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_close_pull_request_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.close_pull_request", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ClosePullRequest", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateBranchRule( + _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.CreateBranchRule") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: secure_source_manager.CreateBranchRuleRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the create branch rule method over HTTP. + + Args: + request (~.secure_source_manager.CreateBranchRuleRequest): + The request object. CreateBranchRuleRequest is the + request to create a branch rule. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_branch_rule( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule._get_transcoded_request( + http_options, request + ) + + body = _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.CreateBranchRule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateBranchRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._CreateBranchRule._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_branch_rule(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_branch_rule_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_branch_rule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateBranchRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateHook( + _BaseSecureSourceManagerRestTransport._BaseCreateHook, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.CreateHook") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: secure_source_manager.CreateHookRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the create hook method over HTTP. + + Args: + request (~.secure_source_manager.CreateHookRequest): + The request object. CreateHookRequest is the request for + creating a hook. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseCreateHook._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_hook(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCreateHook._get_transcoded_request( + http_options, request + ) + + body = _BaseSecureSourceManagerRestTransport._BaseCreateHook._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseCreateHook._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.CreateHook", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateHook", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._CreateHook._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_hook(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_hook_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_hook", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateHook", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateInstance( + _BaseSecureSourceManagerRestTransport._BaseCreateInstance, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.CreateInstance") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: secure_source_manager.CreateInstanceRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the create instance method over HTTP. + + Args: + request (~.secure_source_manager.CreateInstanceRequest): + The request object. CreateInstanceRequest is the request + for creating an instance. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseCreateInstance._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_instance(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCreateInstance._get_transcoded_request( + http_options, request + ) + + body = _BaseSecureSourceManagerRestTransport._BaseCreateInstance._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseCreateInstance._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.CreateInstance", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._CreateInstance._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_instance_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_instance", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateIssue( + _BaseSecureSourceManagerRestTransport._BaseCreateIssue, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.CreateIssue") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: secure_source_manager.CreateIssueRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the create issue method over HTTP. + + Args: + request (~.secure_source_manager.CreateIssueRequest): + The request object. The request to create an issue. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseCreateIssue._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_issue(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCreateIssue._get_transcoded_request( + http_options, request + ) + + body = _BaseSecureSourceManagerRestTransport._BaseCreateIssue._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseCreateIssue._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.CreateIssue", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateIssue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._CreateIssue._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_issue(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_issue_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_issue", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateIssue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateIssueComment( + _BaseSecureSourceManagerRestTransport._BaseCreateIssueComment, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.CreateIssueComment") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: secure_source_manager.CreateIssueCommentRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the create issue comment method over HTTP. + + Args: + request (~.secure_source_manager.CreateIssueCommentRequest): + The request object. The request to create an issue + comment. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseCreateIssueComment._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_issue_comment( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCreateIssueComment._get_transcoded_request( + http_options, request + ) + + body = _BaseSecureSourceManagerRestTransport._BaseCreateIssueComment._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseCreateIssueComment._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.CreateIssueComment", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateIssueComment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + SecureSourceManagerRestTransport._CreateIssueComment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_issue_comment(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_issue_comment_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_issue_comment", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateIssueComment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreatePullRequest( + _BaseSecureSourceManagerRestTransport._BaseCreatePullRequest, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.CreatePullRequest") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: secure_source_manager.CreatePullRequestRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the create pull request method over HTTP. + + Args: + request (~.secure_source_manager.CreatePullRequestRequest): + The request object. CreatePullRequestRequest is the + request to create a pull request. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseCreatePullRequest._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_pull_request( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCreatePullRequest._get_transcoded_request( + http_options, request + ) + + body = _BaseSecureSourceManagerRestTransport._BaseCreatePullRequest._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseCreatePullRequest._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.CreatePullRequest", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreatePullRequest", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + SecureSourceManagerRestTransport._CreatePullRequest._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_pull_request(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_pull_request_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_pull_request", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreatePullRequest", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreatePullRequestComment( + _BaseSecureSourceManagerRestTransport._BaseCreatePullRequestComment, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.CreatePullRequestComment") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: secure_source_manager.CreatePullRequestCommentRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the create pull request + comment method over HTTP. + + Args: + request (~.secure_source_manager.CreatePullRequestCommentRequest): + The request object. The request to create a pull request + comment. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseCreatePullRequestComment._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_pull_request_comment( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCreatePullRequestComment._get_transcoded_request( + http_options, request + ) + + body = _BaseSecureSourceManagerRestTransport._BaseCreatePullRequestComment._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseCreatePullRequestComment._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.CreatePullRequestComment", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreatePullRequestComment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._CreatePullRequestComment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_pull_request_comment(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_pull_request_comment_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_pull_request_comment", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreatePullRequestComment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateRepository( + _BaseSecureSourceManagerRestTransport._BaseCreateRepository, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.CreateRepository") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: secure_source_manager.CreateRepositoryRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the create repository method over HTTP. + + Args: + request (~.secure_source_manager.CreateRepositoryRequest): + The request object. CreateRepositoryRequest is the + request for creating a repository. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseCreateRepository._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_repository( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCreateRepository._get_transcoded_request( + http_options, request + ) + + body = _BaseSecureSourceManagerRestTransport._BaseCreateRepository._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseCreateRepository._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.CreateRepository", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._CreateRepository._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_repository(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_repository_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_repository", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "CreateRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteBranchRule( + _BaseSecureSourceManagerRestTransport._BaseDeleteBranchRule, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.DeleteBranchRule") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.DeleteBranchRuleRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete branch rule method over HTTP. + + Args: + request (~.secure_source_manager.DeleteBranchRuleRequest): + The request object. DeleteBranchRuleRequest is the + request to delete a branch rule. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseDeleteBranchRule._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_branch_rule( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseDeleteBranchRule._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseDeleteBranchRule._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.DeleteBranchRule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteBranchRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._DeleteBranchRule._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_branch_rule(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_branch_rule_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_branch_rule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteBranchRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteHook( + _BaseSecureSourceManagerRestTransport._BaseDeleteHook, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.DeleteHook") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.DeleteHookRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete hook method over HTTP. + + Args: + request (~.secure_source_manager.DeleteHookRequest): + The request object. DeleteHookRequest is the request to + delete a hook. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseDeleteHook._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_hook(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseDeleteHook._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseDeleteHook._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.DeleteHook", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteHook", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._DeleteHook._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_hook(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_hook_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_hook", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteHook", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteInstance( + _BaseSecureSourceManagerRestTransport._BaseDeleteInstance, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.DeleteInstance") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.DeleteInstanceRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete instance method over HTTP. + + Args: + request (~.secure_source_manager.DeleteInstanceRequest): + The request object. DeleteInstanceRequest is the request + for deleting an instance. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseDeleteInstance._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_instance(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseDeleteInstance._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseDeleteInstance._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.DeleteInstance", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._DeleteInstance._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_instance_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_instance", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteIssue( + _BaseSecureSourceManagerRestTransport._BaseDeleteIssue, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.DeleteIssue") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.DeleteIssueRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete issue method over HTTP. + + Args: + request (~.secure_source_manager.DeleteIssueRequest): + The request object. The request to delete an issue. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseDeleteIssue._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_issue(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseDeleteIssue._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseDeleteIssue._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.DeleteIssue", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteIssue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._DeleteIssue._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_issue(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_issue_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_issue", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteIssue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteIssueComment( + _BaseSecureSourceManagerRestTransport._BaseDeleteIssueComment, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.DeleteIssueComment") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.DeleteIssueCommentRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete issue comment method over HTTP. + + Args: + request (~.secure_source_manager.DeleteIssueCommentRequest): + The request object. The request to delete an issue + comment. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseDeleteIssueComment._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_issue_comment( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseDeleteIssueComment._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseDeleteIssueComment._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.DeleteIssueComment", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteIssueComment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + SecureSourceManagerRestTransport._DeleteIssueComment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_issue_comment(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_issue_comment_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_issue_comment", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteIssueComment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeletePullRequestComment( + _BaseSecureSourceManagerRestTransport._BaseDeletePullRequestComment, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.DeletePullRequestComment") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.DeletePullRequestCommentRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete pull request + comment method over HTTP. + + Args: + request (~.secure_source_manager.DeletePullRequestCommentRequest): + The request object. The request to delete a pull request + comment. A Review PullRequestComment + cannot be deleted. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseDeletePullRequestComment._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_pull_request_comment( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseDeletePullRequestComment._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseDeletePullRequestComment._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.DeletePullRequestComment", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeletePullRequestComment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._DeletePullRequestComment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_pull_request_comment(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_pull_request_comment_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_pull_request_comment", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeletePullRequestComment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteRepository( + _BaseSecureSourceManagerRestTransport._BaseDeleteRepository, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.DeleteRepository") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.DeleteRepositoryRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete repository method over HTTP. + + Args: + request (~.secure_source_manager.DeleteRepositoryRequest): + The request object. DeleteRepositoryRequest is the + request to delete a repository. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseDeleteRepository._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_repository( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseDeleteRepository._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseDeleteRepository._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.DeleteRepository", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._DeleteRepository._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_repository(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_repository_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_repository", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "DeleteRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _FetchBlob( + _BaseSecureSourceManagerRestTransport._BaseFetchBlob, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.FetchBlob") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.FetchBlobRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.FetchBlobResponse: + r"""Call the fetch blob method over HTTP. + + Args: + request (~.secure_source_manager.FetchBlobRequest): + The request object. Request message for fetching a blob + (file content) from a repository. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.FetchBlobResponse: + Response message containing the + content of a blob. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseFetchBlob._get_http_options() + ) + + request, metadata = self._interceptor.pre_fetch_blob(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseFetchBlob._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseFetchBlob._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.FetchBlob", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "FetchBlob", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._FetchBlob._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.FetchBlobResponse() + pb_resp = secure_source_manager.FetchBlobResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_fetch_blob(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_fetch_blob_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.FetchBlobResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.fetch_blob", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "FetchBlob", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _FetchTree( + _BaseSecureSourceManagerRestTransport._BaseFetchTree, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.FetchTree") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.FetchTreeRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.FetchTreeResponse: + r"""Call the fetch tree method over HTTP. + + Args: + request (~.secure_source_manager.FetchTreeRequest): + The request object. Request message for fetching a tree + structure from a repository. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.FetchTreeResponse: + Response message containing a list of + TreeEntry objects. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseFetchTree._get_http_options() + ) + + request, metadata = self._interceptor.pre_fetch_tree(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseFetchTree._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseFetchTree._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.FetchTree", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "FetchTree", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._FetchTree._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.FetchTreeResponse() + pb_resp = secure_source_manager.FetchTreeResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_fetch_tree(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_fetch_tree_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.FetchTreeResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.fetch_tree", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "FetchTree", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetBranchRule( + _BaseSecureSourceManagerRestTransport._BaseGetBranchRule, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.GetBranchRule") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.GetBranchRuleRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.BranchRule: + r"""Call the get branch rule method over HTTP. + + Args: + request (~.secure_source_manager.GetBranchRuleRequest): + The request object. GetBranchRuleRequest is the request + for getting a branch rule. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.BranchRule: + Metadata of a BranchRule. BranchRule + is the protection rule to enforce + pre-defined rules on designated branches + within a repository. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseGetBranchRule._get_http_options() + ) + + request, metadata = self._interceptor.pre_get_branch_rule(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetBranchRule._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseGetBranchRule._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetBranchRule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetBranchRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._GetBranchRule._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.BranchRule() + pb_resp = secure_source_manager.BranchRule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_branch_rule(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_branch_rule_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.BranchRule.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_branch_rule", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetBranchRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetHook( + _BaseSecureSourceManagerRestTransport._BaseGetHook, SecureSourceManagerRestStub + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.GetHook") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.GetHookRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.Hook: + r"""Call the get hook method over HTTP. + + Args: + request (~.secure_source_manager.GetHookRequest): + The request object. GetHookRequest is the request for + getting a hook. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.Hook: + Metadata of a Secure Source Manager + Hook. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseGetHook._get_http_options() + ) + + request, metadata = self._interceptor.pre_get_hook(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetHook._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseGetHook._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetHook", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetHook", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._GetHook._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.Hook() + pb_resp = secure_source_manager.Hook.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_hook(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_hook_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.Hook.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_hook", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetHook", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetIamPolicyRepo( + _BaseSecureSourceManagerRestTransport._BaseGetIamPolicyRepo, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.GetIamPolicyRepo") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: iam_policy_pb2.GetIamPolicyRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> policy_pb2.Policy: + r"""Call the get iam policy repo method over HTTP. + + Args: + request (~.iam_policy_pb2.GetIamPolicyRequest): + The request object. Request message for ``GetIamPolicy`` method. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.policy_pb2.Policy: + An Identity and Access Management (IAM) policy, which + specifies access controls for Google Cloud resources. + + A ``Policy`` is a collection of ``bindings``. A + ``binding`` binds one or more ``members``, or + principals, to a single ``role``. Principals can be user + accounts, service accounts, Google groups, and domains + (such as G Suite). A ``role`` is a named list of + permissions; each ``role`` can be an IAM predefined role + or a user-created custom role. + + For some types of Google Cloud resources, a ``binding`` + can also specify a ``condition``, which is a logical + expression that allows access to a resource only if the + expression evaluates to ``true``. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the `IAM + documentation `__. + + **JSON example:** + + :: + + { + "bindings": [ + { + "role": "roles/resourcemanager.organizationAdmin", + "members": [ + "user:mike@example.com", + "group:admins@example.com", + "domain:google.com", + "serviceAccount:my-project-id@appspot.gserviceaccount.com" + ] + }, + { + "role": "roles/resourcemanager.organizationViewer", + "members": [ + "user:eve@example.com" + ], + "condition": { + "title": "expirable access", + "description": "Does not grant access after Sep 2020", + "expression": "request.time < + timestamp('2020-10-01T00:00:00.000Z')", + } + } + ], + "etag": "BwWWja0YfJA=", + "version": 3 + } + + **YAML example:** + + :: + + bindings: + - members: + - user:mike@example.com + - group:admins@example.com + - domain:google.com + - serviceAccount:my-project-id@appspot.gserviceaccount.com + role: roles/resourcemanager.organizationAdmin + - members: + - user:eve@example.com + role: roles/resourcemanager.organizationViewer + condition: + title: expirable access + description: Does not grant access after Sep 2020 + expression: request.time < timestamp('2020-10-01T00:00:00.000Z') + etag: BwWWja0YfJA= + version: 3 + + For a description of IAM and its features, see the `IAM + documentation `__. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseGetIamPolicyRepo._get_http_options() + ) + + request, metadata = self._interceptor.pre_get_iam_policy_repo( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetIamPolicyRepo._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseGetIamPolicyRepo._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetIamPolicyRepo", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetIamPolicyRepo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._GetIamPolicyRepo._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = policy_pb2.Policy() + pb_resp = resp + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_iam_policy_repo(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_iam_policy_repo_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_iam_policy_repo", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetIamPolicyRepo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetInstance( + _BaseSecureSourceManagerRestTransport._BaseGetInstance, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.GetInstance") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.GetInstanceRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.Instance: + r"""Call the get instance method over HTTP. + + Args: + request (~.secure_source_manager.GetInstanceRequest): + The request object. GetInstanceRequest is the request for + getting an instance. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.Instance: + A resource that represents a Secure + Source Manager instance. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseGetInstance._get_http_options() + ) + + request, metadata = self._interceptor.pre_get_instance(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetInstance._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseGetInstance._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetInstance", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._GetInstance._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.Instance() + pb_resp = secure_source_manager.Instance.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_instance_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.Instance.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_instance", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetIssue( + _BaseSecureSourceManagerRestTransport._BaseGetIssue, SecureSourceManagerRestStub + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.GetIssue") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.GetIssueRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.Issue: + r"""Call the get issue method over HTTP. + + Args: + request (~.secure_source_manager.GetIssueRequest): + The request object. The request to get an issue. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.Issue: + Metadata of an Issue. + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseGetIssue._get_http_options() + ) + + request, metadata = self._interceptor.pre_get_issue(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetIssue._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseGetIssue._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetIssue", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetIssue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._GetIssue._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.Issue() + pb_resp = secure_source_manager.Issue.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_issue(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_issue_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.Issue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_issue", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetIssue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetIssueComment( + _BaseSecureSourceManagerRestTransport._BaseGetIssueComment, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.GetIssueComment") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.GetIssueCommentRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.IssueComment: + r"""Call the get issue comment method over HTTP. + + Args: + request (~.secure_source_manager.GetIssueCommentRequest): + The request object. The request to get an issue comment. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.IssueComment: + IssueComment represents a comment on + an issue. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseGetIssueComment._get_http_options() + ) + + request, metadata = self._interceptor.pre_get_issue_comment( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetIssueComment._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseGetIssueComment._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetIssueComment", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetIssueComment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._GetIssueComment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.IssueComment() + pb_resp = secure_source_manager.IssueComment.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_issue_comment(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_issue_comment_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.IssueComment.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_issue_comment", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetIssueComment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetPullRequest( + _BaseSecureSourceManagerRestTransport._BaseGetPullRequest, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.GetPullRequest") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.GetPullRequestRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.PullRequest: + r"""Call the get pull request method over HTTP. + + Args: + request (~.secure_source_manager.GetPullRequestRequest): + The request object. GetPullRequestRequest is the request + to get a pull request. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.PullRequest: + Metadata of a PullRequest. + PullRequest is the request from a user + to merge a branch (head) into another + branch (base). + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseGetPullRequest._get_http_options() + ) + + request, metadata = self._interceptor.pre_get_pull_request( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetPullRequest._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseGetPullRequest._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetPullRequest", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetPullRequest", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._GetPullRequest._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.PullRequest() + pb_resp = secure_source_manager.PullRequest.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_pull_request(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_pull_request_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.PullRequest.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_pull_request", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetPullRequest", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetPullRequestComment( + _BaseSecureSourceManagerRestTransport._BaseGetPullRequestComment, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.GetPullRequestComment") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.GetPullRequestCommentRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.PullRequestComment: + r"""Call the get pull request comment method over HTTP. + + Args: + request (~.secure_source_manager.GetPullRequestCommentRequest): + The request object. The request to get a pull request + comment. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.PullRequestComment: + PullRequestComment represents a + comment on a pull request. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseGetPullRequestComment._get_http_options() + ) + + request, metadata = self._interceptor.pre_get_pull_request_comment( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetPullRequestComment._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseGetPullRequestComment._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetPullRequestComment", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetPullRequestComment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + SecureSourceManagerRestTransport._GetPullRequestComment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.PullRequestComment() + pb_resp = secure_source_manager.PullRequestComment.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_pull_request_comment(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_pull_request_comment_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.PullRequestComment.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_pull_request_comment", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetPullRequestComment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetRepository( + _BaseSecureSourceManagerRestTransport._BaseGetRepository, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.GetRepository") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.GetRepositoryRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.Repository: + r"""Call the get repository method over HTTP. + + Args: + request (~.secure_source_manager.GetRepositoryRequest): + The request object. GetRepositoryRequest is the request + for getting a repository. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.Repository: + Metadata of a Secure Source Manager + repository. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseGetRepository._get_http_options() + ) + + request, metadata = self._interceptor.pre_get_repository(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetRepository._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseGetRepository._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetRepository", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._GetRepository._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.Repository() + pb_resp = secure_source_manager.Repository.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_repository(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_repository_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.Repository.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_repository", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "GetRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListBranchRules( + _BaseSecureSourceManagerRestTransport._BaseListBranchRules, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.ListBranchRules") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.ListBranchRulesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.ListBranchRulesResponse: + r"""Call the list branch rules method over HTTP. + + Args: + request (~.secure_source_manager.ListBranchRulesRequest): + The request object. ListBranchRulesRequest is the request + to list branch rules. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.ListBranchRulesResponse: + ListBranchRulesResponse is the + response to listing branchRules. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseListBranchRules._get_http_options() + ) + + request, metadata = self._interceptor.pre_list_branch_rules( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListBranchRules._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseListBranchRules._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ListBranchRules", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListBranchRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._ListBranchRules._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.ListBranchRulesResponse() + pb_resp = secure_source_manager.ListBranchRulesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_branch_rules(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_branch_rules_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + secure_source_manager.ListBranchRulesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_branch_rules", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListBranchRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListHooks( + _BaseSecureSourceManagerRestTransport._BaseListHooks, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.ListHooks") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.ListHooksRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.ListHooksResponse: + r"""Call the list hooks method over HTTP. + + Args: + request (~.secure_source_manager.ListHooksRequest): + The request object. ListHooksRequest is request to list + hooks. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.ListHooksResponse: + ListHooksResponse is response to list + hooks. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseListHooks._get_http_options() + ) + + request, metadata = self._interceptor.pre_list_hooks(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListHooks._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseListHooks._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ListHooks", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListHooks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._ListHooks._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.ListHooksResponse() + pb_resp = secure_source_manager.ListHooksResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_hooks(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_hooks_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.ListHooksResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_hooks", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListHooks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListInstances( + _BaseSecureSourceManagerRestTransport._BaseListInstances, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.ListInstances") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.ListInstancesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.ListInstancesResponse: + r"""Call the list instances method over HTTP. + + Args: + request (~.secure_source_manager.ListInstancesRequest): + The request object. ListInstancesRequest is the request + to list instances. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.ListInstancesResponse: + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseListInstances._get_http_options() + ) + + request, metadata = self._interceptor.pre_list_instances(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListInstances._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseListInstances._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ListInstances", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._ListInstances._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.ListInstancesResponse() + pb_resp = secure_source_manager.ListInstancesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_instances(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_instances_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + secure_source_manager.ListInstancesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_instances", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListIssueComments( + _BaseSecureSourceManagerRestTransport._BaseListIssueComments, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.ListIssueComments") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.ListIssueCommentsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.ListIssueCommentsResponse: + r"""Call the list issue comments method over HTTP. + + Args: + request (~.secure_source_manager.ListIssueCommentsRequest): + The request object. The request to list issue comments. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.ListIssueCommentsResponse: + The response to list issue comments. + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseListIssueComments._get_http_options() + ) + + request, metadata = self._interceptor.pre_list_issue_comments( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListIssueComments._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseListIssueComments._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ListIssueComments", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListIssueComments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + SecureSourceManagerRestTransport._ListIssueComments._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client - certificate to configure mutual TLS HTTP channel. It is ignored - if ``channel`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you are developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - url_scheme: the protocol scheme for the API endpoint. Normally - "https", but for testing or local servers, - "http" can be specified. - """ - # Run the base constructor - # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. - # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the - # credentials object - super().__init__( - host=host, - credentials=credentials, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - url_scheme=url_scheme, - api_audience=api_audience, - ) - self._session = AuthorizedSession( - self._credentials, default_host=self.DEFAULT_HOST - ) - self._operations_client: Optional[operations_v1.AbstractOperationsClient] = None - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or SecureSourceManagerRestInterceptor() - self._prep_wrapped_messages(client_info) + # Return the response + resp = secure_source_manager.ListIssueCommentsResponse() + pb_resp = secure_source_manager.ListIssueCommentsResponse.pb(resp) - @property - def operations_client(self) -> operations_v1.AbstractOperationsClient: - """Create the client designed to process long-running operations. + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - This property caches on the instance; repeated calls return the same - client. - """ - # Only create a new client if we do not already have one. - if self._operations_client is None: - http_options: Dict[str, List[Dict[str, str]]] = { - "google.longrunning.Operations.CancelOperation": [ - { - "method": "post", - "uri": "/v1/{name=projects/*/locations/*/operations/*}:cancel", - "body": "*", - }, - ], - "google.longrunning.Operations.DeleteOperation": [ - { - "method": "delete", - "uri": "/v1/{name=projects/*/locations/*/operations/*}", + resp = self._interceptor.post_list_issue_comments(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_issue_comments_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + secure_source_manager.ListIssueCommentsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_issue_comments", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListIssueComments", + "metadata": http_response["headers"], + "httpResponse": http_response, }, - ], - "google.longrunning.Operations.GetOperation": [ - { - "method": "get", - "uri": "/v1/{name=projects/*/locations/*/operations/*}", + ) + return resp + + class _ListIssues( + _BaseSecureSourceManagerRestTransport._BaseListIssues, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.ListIssues") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.ListIssuesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.ListIssuesResponse: + r"""Call the list issues method over HTTP. + + Args: + request (~.secure_source_manager.ListIssuesRequest): + The request object. The request to list issues. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.ListIssuesResponse: + The response to list issues. + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseListIssues._get_http_options() + ) + + request, metadata = self._interceptor.pre_list_issues(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListIssues._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseListIssues._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ListIssues", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListIssues", + "httpRequest": http_request, + "metadata": http_request["headers"], }, - ], - "google.longrunning.Operations.ListOperations": [ - { - "method": "get", - "uri": "/v1/{name=projects/*/locations/*}/operations", + ) + + # Send the request + response = SecureSourceManagerRestTransport._ListIssues._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.ListIssuesResponse() + pb_resp = secure_source_manager.ListIssuesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_issues(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_issues_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = secure_source_manager.ListIssuesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_issues", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListIssues", + "metadata": http_response["headers"], + "httpResponse": http_response, }, - ], - } + ) + return resp + + class _ListPullRequestComments( + _BaseSecureSourceManagerRestTransport._BaseListPullRequestComments, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.ListPullRequestComments") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: secure_source_manager.ListPullRequestCommentsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> secure_source_manager.ListPullRequestCommentsResponse: + r"""Call the list pull request + comments method over HTTP. + + Args: + request (~.secure_source_manager.ListPullRequestCommentsRequest): + The request object. The request to list pull request + comments. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.ListPullRequestCommentsResponse: + The response to list pull request + comments. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseListPullRequestComments._get_http_options() + ) - rest_transport = operations_v1.OperationsRestTransport( - host=self._host, - # use the credentials which are saved - credentials=self._credentials, - scopes=self._scopes, - http_options=http_options, - path_prefix="v1", + request, metadata = self._interceptor.pre_list_pull_request_comments( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListPullRequestComments._get_transcoded_request( + http_options, request ) - self._operations_client = operations_v1.AbstractOperationsClient( - transport=rest_transport + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseListPullRequestComments._get_query_params_json( + transcoded_request ) - # Return the client from cache. - return self._operations_client + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ListPullRequestComments", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListPullRequestComments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) - class _CreateBranchRule( - _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule, + # Send the request + response = ( + SecureSourceManagerRestTransport._ListPullRequestComments._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = secure_source_manager.ListPullRequestCommentsResponse() + pb_resp = secure_source_manager.ListPullRequestCommentsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_pull_request_comments(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_pull_request_comments_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + secure_source_manager.ListPullRequestCommentsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_pull_request_comments", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "ListPullRequestComments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListPullRequestFileDiffs( + _BaseSecureSourceManagerRestTransport._BaseListPullRequestFileDiffs, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.CreateBranchRule") + return hash("SecureSourceManagerRestTransport.ListPullRequestFileDiffs") @staticmethod def _get_response( @@ -1417,57 +8843,54 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: secure_source_manager.CreateBranchRuleRequest, + request: secure_source_manager.ListPullRequestFileDiffsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operations_pb2.Operation: - r"""Call the create branch rule method over HTTP. - - Args: - request (~.secure_source_manager.CreateBranchRuleRequest): - The request object. CreateBranchRuleRequest is the - request to create a branch rule. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + ) -> secure_source_manager.ListPullRequestFileDiffsResponse: + r"""Call the list pull request file + diffs method over HTTP. + + Args: + request (~.secure_source_manager.ListPullRequestFileDiffsRequest): + The request object. ListPullRequestFileDiffsRequest is + the request to list pull request file + diffs. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.secure_source_manager.ListPullRequestFileDiffsResponse: + ListPullRequestFileDiffsResponse is + the response containing file diffs + returned from ListPullRequestFileDiffs. """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseListPullRequestFileDiffs._get_http_options() ) - request, metadata = self._interceptor.pre_create_branch_rule( + request, metadata = self._interceptor.pre_list_pull_request_file_diffs( request, metadata ) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule._get_transcoded_request( + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListPullRequestFileDiffs._get_transcoded_request( http_options, request ) - body = _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule._get_request_body_json( - transcoded_request - ) - # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseListPullRequestFileDiffs._get_query_params_json( transcoded_request ) @@ -1479,7 +8902,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = json_format.MessageToJson(request) + request_payload = type(request).to_json(request) except: request_payload = None http_request = { @@ -1489,24 +8912,23 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.CreateBranchRule", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ListPullRequestFileDiffs", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "CreateBranchRule", + "rpcName": "ListPullRequestFileDiffs", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._CreateBranchRule._get_response( + response = SecureSourceManagerRestTransport._ListPullRequestFileDiffs._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, - body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1515,19 +8937,25 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = secure_source_manager.ListPullRequestFileDiffsResponse() + pb_resp = secure_source_manager.ListPullRequestFileDiffsResponse.pb(resp) - resp = self._interceptor.post_create_branch_rule(resp) + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_pull_request_file_diffs(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_branch_rule_with_metadata( + resp, _ = self._interceptor.post_list_pull_request_file_diffs_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = json_format.MessageToJson(resp) + response_payload = ( + secure_source_manager.ListPullRequestFileDiffsResponse.to_json( + response + ) + ) except: response_payload = None http_response = { @@ -1536,22 +8964,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_branch_rule", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_pull_request_file_diffs", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "CreateBranchRule", + "rpcName": "ListPullRequestFileDiffs", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _CreateInstance( - _BaseSecureSourceManagerRestTransport._BaseCreateInstance, + class _ListPullRequests( + _BaseSecureSourceManagerRestTransport._BaseListPullRequests, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.CreateInstance") + return hash("SecureSourceManagerRestTransport.ListPullRequests") @staticmethod def _get_response( @@ -1572,24 +9000,23 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: secure_source_manager.CreateInstanceRequest, + request: secure_source_manager.ListPullRequestsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operations_pb2.Operation: - r"""Call the create instance method over HTTP. + ) -> secure_source_manager.ListPullRequestsResponse: + r"""Call the list pull requests method over HTTP. Args: - request (~.secure_source_manager.CreateInstanceRequest): - The request object. CreateInstanceRequest is the request - for creating an instance. + request (~.secure_source_manager.ListPullRequestsRequest): + The request object. ListPullRequestsRequest is the + request to list pull requests. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1599,28 +9026,25 @@ def __call__( be of type `bytes`. Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + ~.secure_source_manager.ListPullRequestsResponse: + ListPullRequestsResponse is the + response to list pull requests. """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseCreateInstance._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseListPullRequests._get_http_options() ) - request, metadata = self._interceptor.pre_create_instance(request, metadata) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCreateInstance._get_transcoded_request( - http_options, request + request, metadata = self._interceptor.pre_list_pull_requests( + request, metadata ) - - body = _BaseSecureSourceManagerRestTransport._BaseCreateInstance._get_request_body_json( - transcoded_request + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListPullRequests._get_transcoded_request( + http_options, request ) # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseCreateInstance._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseListPullRequests._get_query_params_json( transcoded_request ) @@ -1632,7 +9056,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = json_format.MessageToJson(request) + request_payload = type(request).to_json(request) except: request_payload = None http_request = { @@ -1642,24 +9066,23 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.CreateInstance", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ListPullRequests", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "CreateInstance", + "rpcName": "ListPullRequests", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._CreateInstance._get_response( + response = SecureSourceManagerRestTransport._ListPullRequests._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, - body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1668,19 +9091,23 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = secure_source_manager.ListPullRequestsResponse() + pb_resp = secure_source_manager.ListPullRequestsResponse.pb(resp) - resp = self._interceptor.post_create_instance(resp) + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_pull_requests(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_instance_with_metadata( + resp, _ = self._interceptor.post_list_pull_requests_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = json_format.MessageToJson(resp) + response_payload = ( + secure_source_manager.ListPullRequestsResponse.to_json(response) + ) except: response_payload = None http_response = { @@ -1689,22 +9116,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_instance", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_pull_requests", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "CreateInstance", + "rpcName": "ListPullRequests", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _CreateRepository( - _BaseSecureSourceManagerRestTransport._BaseCreateRepository, + class _ListRepositories( + _BaseSecureSourceManagerRestTransport._BaseListRepositories, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.CreateRepository") + return hash("SecureSourceManagerRestTransport.ListRepositories") @staticmethod def _get_response( @@ -1725,24 +9152,23 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, ) return response def __call__( self, - request: secure_source_manager.CreateRepositoryRequest, + request: secure_source_manager.ListRepositoriesRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operations_pb2.Operation: - r"""Call the create repository method over HTTP. + ) -> secure_source_manager.ListRepositoriesResponse: + r"""Call the list repositories method over HTTP. Args: - request (~.secure_source_manager.CreateRepositoryRequest): - The request object. CreateRepositoryRequest is the - request for creating a repository. + request (~.secure_source_manager.ListRepositoriesRequest): + The request object. ListRepositoriesRequest is request to + list repositories. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1752,30 +9178,23 @@ def __call__( be of type `bytes`. Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. + ~.secure_source_manager.ListRepositoriesResponse: """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseCreateRepository._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseListRepositories._get_http_options() ) - request, metadata = self._interceptor.pre_create_repository( + request, metadata = self._interceptor.pre_list_repositories( request, metadata ) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseCreateRepository._get_transcoded_request( + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListRepositories._get_transcoded_request( http_options, request ) - body = _BaseSecureSourceManagerRestTransport._BaseCreateRepository._get_request_body_json( - transcoded_request - ) - # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseCreateRepository._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseListRepositories._get_query_params_json( transcoded_request ) @@ -1787,7 +9206,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = json_format.MessageToJson(request) + request_payload = type(request).to_json(request) except: request_payload = None http_request = { @@ -1797,24 +9216,23 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.CreateRepository", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ListRepositories", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "CreateRepository", + "rpcName": "ListRepositories", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._CreateRepository._get_response( + response = SecureSourceManagerRestTransport._ListRepositories._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, - body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1823,19 +9241,23 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = secure_source_manager.ListRepositoriesResponse() + pb_resp = secure_source_manager.ListRepositoriesResponse.pb(resp) - resp = self._interceptor.post_create_repository(resp) + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_repositories(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_repository_with_metadata( + resp, _ = self._interceptor.post_list_repositories_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = json_format.MessageToJson(resp) + response_payload = ( + secure_source_manager.ListRepositoriesResponse.to_json(response) + ) except: response_payload = None http_response = { @@ -1844,22 +9266,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_repository", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_repositories", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "CreateRepository", + "rpcName": "ListRepositories", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _DeleteBranchRule( - _BaseSecureSourceManagerRestTransport._BaseDeleteBranchRule, + class _MergePullRequest( + _BaseSecureSourceManagerRestTransport._BaseMergePullRequest, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.DeleteBranchRule") + return hash("SecureSourceManagerRestTransport.MergePullRequest") @staticmethod def _get_response( @@ -1880,23 +9302,24 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: secure_source_manager.DeleteBranchRuleRequest, + request: secure_source_manager.MergePullRequestRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: - r"""Call the delete branch rule method over HTTP. + r"""Call the merge pull request method over HTTP. Args: - request (~.secure_source_manager.DeleteBranchRuleRequest): - The request object. DeleteBranchRuleRequest is the - request to delete a branch rule. + request (~.secure_source_manager.MergePullRequestRequest): + The request object. MergePullRequestRequest is the + request to merge a pull request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1914,18 +9337,22 @@ def __call__( """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseDeleteBranchRule._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseMergePullRequest._get_http_options() ) - request, metadata = self._interceptor.pre_delete_branch_rule( + request, metadata = self._interceptor.pre_merge_pull_request( request, metadata ) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseDeleteBranchRule._get_transcoded_request( + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseMergePullRequest._get_transcoded_request( http_options, request ) + body = _BaseSecureSourceManagerRestTransport._BaseMergePullRequest._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseDeleteBranchRule._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseMergePullRequest._get_query_params_json( transcoded_request ) @@ -1947,23 +9374,24 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.DeleteBranchRule", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.MergePullRequest", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "DeleteBranchRule", + "rpcName": "MergePullRequest", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._DeleteBranchRule._get_response( + response = SecureSourceManagerRestTransport._MergePullRequest._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1975,9 +9403,9 @@ def __call__( resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_branch_rule(resp) + resp = self._interceptor.post_merge_pull_request(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_branch_rule_with_metadata( + resp, _ = self._interceptor.post_merge_pull_request_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -1993,22 +9421,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_branch_rule", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.merge_pull_request", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "DeleteBranchRule", + "rpcName": "MergePullRequest", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _DeleteInstance( - _BaseSecureSourceManagerRestTransport._BaseDeleteInstance, + class _OpenIssue( + _BaseSecureSourceManagerRestTransport._BaseOpenIssue, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.DeleteInstance") + return hash("SecureSourceManagerRestTransport.OpenIssue") @staticmethod def _get_response( @@ -2029,23 +9457,23 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: secure_source_manager.DeleteInstanceRequest, + request: secure_source_manager.OpenIssueRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: - r"""Call the delete instance method over HTTP. + r"""Call the open issue method over HTTP. Args: - request (~.secure_source_manager.DeleteInstanceRequest): - The request object. DeleteInstanceRequest is the request - for deleting an instance. + request (~.secure_source_manager.OpenIssueRequest): + The request object. The request to open an issue. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2063,16 +9491,20 @@ def __call__( """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseDeleteInstance._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseOpenIssue._get_http_options() ) - request, metadata = self._interceptor.pre_delete_instance(request, metadata) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseDeleteInstance._get_transcoded_request( + request, metadata = self._interceptor.pre_open_issue(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseOpenIssue._get_transcoded_request( http_options, request ) + body = _BaseSecureSourceManagerRestTransport._BaseOpenIssue._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseDeleteInstance._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseOpenIssue._get_query_params_json( transcoded_request ) @@ -2094,23 +9526,24 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.DeleteInstance", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.OpenIssue", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "DeleteInstance", + "rpcName": "OpenIssue", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._DeleteInstance._get_response( + response = SecureSourceManagerRestTransport._OpenIssue._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2122,9 +9555,9 @@ def __call__( resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_instance(resp) + resp = self._interceptor.post_open_issue(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_instance_with_metadata( + resp, _ = self._interceptor.post_open_issue_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -2140,22 +9573,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_instance", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.open_issue", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "DeleteInstance", + "rpcName": "OpenIssue", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _DeleteRepository( - _BaseSecureSourceManagerRestTransport._BaseDeleteRepository, + class _OpenPullRequest( + _BaseSecureSourceManagerRestTransport._BaseOpenPullRequest, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.DeleteRepository") + return hash("SecureSourceManagerRestTransport.OpenPullRequest") @staticmethod def _get_response( @@ -2176,23 +9609,24 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: secure_source_manager.DeleteRepositoryRequest, + request: secure_source_manager.OpenPullRequestRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: - r"""Call the delete repository method over HTTP. + r"""Call the open pull request method over HTTP. Args: - request (~.secure_source_manager.DeleteRepositoryRequest): - The request object. DeleteRepositoryRequest is the - request to delete a repository. + request (~.secure_source_manager.OpenPullRequestRequest): + The request object. OpenPullRequestRequest is the request + to open a pull request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2210,18 +9644,22 @@ def __call__( """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseDeleteRepository._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseOpenPullRequest._get_http_options() ) - request, metadata = self._interceptor.pre_delete_repository( + request, metadata = self._interceptor.pre_open_pull_request( request, metadata ) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseDeleteRepository._get_transcoded_request( + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseOpenPullRequest._get_transcoded_request( http_options, request ) + body = _BaseSecureSourceManagerRestTransport._BaseOpenPullRequest._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseDeleteRepository._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseOpenPullRequest._get_query_params_json( transcoded_request ) @@ -2243,23 +9681,24 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.DeleteRepository", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.OpenPullRequest", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "DeleteRepository", + "rpcName": "OpenPullRequest", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._DeleteRepository._get_response( + response = SecureSourceManagerRestTransport._OpenPullRequest._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2271,9 +9710,9 @@ def __call__( resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_delete_repository(resp) + resp = self._interceptor.post_open_pull_request(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_repository_with_metadata( + resp, _ = self._interceptor.post_open_pull_request_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -2289,22 +9728,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_repository", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.open_pull_request", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "DeleteRepository", + "rpcName": "OpenPullRequest", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _GetBranchRule( - _BaseSecureSourceManagerRestTransport._BaseGetBranchRule, + class _ResolvePullRequestComments( + _BaseSecureSourceManagerRestTransport._BaseResolvePullRequestComments, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.GetBranchRule") + return hash("SecureSourceManagerRestTransport.ResolvePullRequestComments") @staticmethod def _get_response( @@ -2325,51 +9764,58 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: secure_source_manager.GetBranchRuleRequest, + request: secure_source_manager.ResolvePullRequestCommentsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> secure_source_manager.BranchRule: - r"""Call the get branch rule method over HTTP. - - Args: - request (~.secure_source_manager.GetBranchRuleRequest): - The request object. GetBranchRuleRequest is the request - for getting a branch rule. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.secure_source_manager.BranchRule: - Metadata of a BranchRule. BranchRule - is the protection rule to enforce - pre-defined rules on desginated branches - within a repository. + ) -> operations_pb2.Operation: + r"""Call the resolve pull request + comments method over HTTP. + + Args: + request (~.secure_source_manager.ResolvePullRequestCommentsRequest): + The request object. The request to resolve multiple pull + request comments. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseGetBranchRule._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseResolvePullRequestComments._get_http_options() ) - request, metadata = self._interceptor.pre_get_branch_rule(request, metadata) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetBranchRule._get_transcoded_request( + request, metadata = self._interceptor.pre_resolve_pull_request_comments( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseResolvePullRequestComments._get_transcoded_request( http_options, request ) + body = _BaseSecureSourceManagerRestTransport._BaseResolvePullRequestComments._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseGetBranchRule._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseResolvePullRequestComments._get_query_params_json( transcoded_request ) @@ -2381,7 +9827,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = type(request).to_json(request) + request_payload = json_format.MessageToJson(request) except: request_payload = None http_request = { @@ -2391,23 +9837,24 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetBranchRule", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ResolvePullRequestComments", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "GetBranchRule", + "rpcName": "ResolvePullRequestComments", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._GetBranchRule._get_response( + response = SecureSourceManagerRestTransport._ResolvePullRequestComments._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2416,23 +9863,22 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = secure_source_manager.BranchRule() - pb_resp = secure_source_manager.BranchRule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_branch_rule(resp) + resp = self._interceptor.post_resolve_pull_request_comments(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_branch_rule_with_metadata( + ( + resp, + _, + ) = self._interceptor.post_resolve_pull_request_comments_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = secure_source_manager.BranchRule.to_json( - response - ) + response_payload = json_format.MessageToJson(resp) except: response_payload = None http_response = { @@ -2441,22 +9887,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_branch_rule", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.resolve_pull_request_comments", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "GetBranchRule", + "rpcName": "ResolvePullRequestComments", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _GetIamPolicyRepo( - _BaseSecureSourceManagerRestTransport._BaseGetIamPolicyRepo, + class _SetIamPolicyRepo( + _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.GetIamPolicyRepo") + return hash("SecureSourceManagerRestTransport.SetIamPolicyRepo") @staticmethod def _get_response( @@ -2477,22 +9923,23 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: iam_policy_pb2.GetIamPolicyRequest, + request: iam_policy_pb2.SetIamPolicyRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: - r"""Call the get iam policy repo method over HTTP. + r"""Call the set iam policy repo method over HTTP. Args: - request (~.iam_policy_pb2.GetIamPolicyRequest): - The request object. Request message for ``GetIamPolicy`` method. + request (~.iam_policy_pb2.SetIamPolicyRequest): + The request object. Request message for ``SetIamPolicy`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2576,24 +10023,181 @@ def __call__( etag: BwWWja0YfJA= version: 3 - For a description of IAM and its features, see the `IAM - documentation `__. + For a description of IAM and its features, see the `IAM + documentation `__. + + """ + + http_options = ( + _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo._get_http_options() + ) + + request, metadata = self._interceptor.pre_set_iam_policy_repo( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo._get_transcoded_request( + http_options, request + ) + + body = _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.SetIamPolicyRepo", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "SetIamPolicyRepo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = SecureSourceManagerRestTransport._SetIamPolicyRepo._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = policy_pb2.Policy() + pb_resp = resp + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_set_iam_policy_repo(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_set_iam_policy_repo_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.set_iam_policy_repo", + extra={ + "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "rpcName": "SetIamPolicyRepo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _TestIamPermissionsRepo( + _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo, + SecureSourceManagerRestStub, + ): + def __hash__(self): + return hash("SecureSourceManagerRestTransport.TestIamPermissionsRepo") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: iam_policy_pb2.TestIamPermissionsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> iam_policy_pb2.TestIamPermissionsResponse: + r"""Call the test iam permissions repo method over HTTP. + + Args: + request (~.iam_policy_pb2.TestIamPermissionsRequest): + The request object. Request message for ``TestIamPermissions`` method. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + Returns: + ~.iam_policy_pb2.TestIamPermissionsResponse: + Response message for ``TestIamPermissions`` method. """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseGetIamPolicyRepo._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo._get_http_options() ) - request, metadata = self._interceptor.pre_get_iam_policy_repo( + request, metadata = self._interceptor.pre_test_iam_permissions_repo( request, metadata ) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetIamPolicyRepo._get_transcoded_request( + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo._get_transcoded_request( http_options, request ) + body = _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseGetIamPolicyRepo._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo._get_query_params_json( transcoded_request ) @@ -2615,23 +10219,26 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetIamPolicyRepo", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.TestIamPermissionsRepo", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "GetIamPolicyRepo", + "rpcName": "TestIamPermissionsRepo", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._GetIamPolicyRepo._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, + response = ( + SecureSourceManagerRestTransport._TestIamPermissionsRepo._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2640,14 +10247,14 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = policy_pb2.Policy() + resp = iam_policy_pb2.TestIamPermissionsResponse() pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_iam_policy_repo(resp) + resp = self._interceptor.post_test_iam_permissions_repo(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_iam_policy_repo_with_metadata( + resp, _ = self._interceptor.post_test_iam_permissions_repo_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -2663,22 +10270,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_iam_policy_repo", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.test_iam_permissions_repo", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "GetIamPolicyRepo", + "rpcName": "TestIamPermissionsRepo", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _GetInstance( - _BaseSecureSourceManagerRestTransport._BaseGetInstance, + class _UnresolvePullRequestComments( + _BaseSecureSourceManagerRestTransport._BaseUnresolvePullRequestComments, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.GetInstance") + return hash("SecureSourceManagerRestTransport.UnresolvePullRequestComments") @staticmethod def _get_response( @@ -2699,49 +10306,58 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: secure_source_manager.GetInstanceRequest, + request: secure_source_manager.UnresolvePullRequestCommentsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> secure_source_manager.Instance: - r"""Call the get instance method over HTTP. - - Args: - request (~.secure_source_manager.GetInstanceRequest): - The request object. GetInstanceRequest is the request for - getting an instance. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.secure_source_manager.Instance: - A resource that represents a Secure - Source Manager instance. + ) -> operations_pb2.Operation: + r"""Call the unresolve pull request + comments method over HTTP. + + Args: + request (~.secure_source_manager.UnresolvePullRequestCommentsRequest): + The request object. The request to unresolve multiple + pull request comments. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseGetInstance._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseUnresolvePullRequestComments._get_http_options() ) - request, metadata = self._interceptor.pre_get_instance(request, metadata) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetInstance._get_transcoded_request( + request, metadata = self._interceptor.pre_unresolve_pull_request_comments( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseUnresolvePullRequestComments._get_transcoded_request( http_options, request ) + body = _BaseSecureSourceManagerRestTransport._BaseUnresolvePullRequestComments._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseGetInstance._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseUnresolvePullRequestComments._get_query_params_json( transcoded_request ) @@ -2753,7 +10369,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = type(request).to_json(request) + request_payload = json_format.MessageToJson(request) except: request_payload = None http_request = { @@ -2763,23 +10379,24 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetInstance", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.UnresolvePullRequestComments", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "GetInstance", + "rpcName": "UnresolvePullRequestComments", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._GetInstance._get_response( + response = SecureSourceManagerRestTransport._UnresolvePullRequestComments._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2788,21 +10405,22 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = secure_source_manager.Instance() - pb_resp = secure_source_manager.Instance.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_instance(resp) + resp = self._interceptor.post_unresolve_pull_request_comments(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_instance_with_metadata( + ( + resp, + _, + ) = self._interceptor.post_unresolve_pull_request_comments_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = secure_source_manager.Instance.to_json(response) + response_payload = json_format.MessageToJson(resp) except: response_payload = None http_response = { @@ -2811,22 +10429,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_instance", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.unresolve_pull_request_comments", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "GetInstance", + "rpcName": "UnresolvePullRequestComments", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _GetRepository( - _BaseSecureSourceManagerRestTransport._BaseGetRepository, + class _UpdateBranchRule( + _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.GetRepository") + return hash("SecureSourceManagerRestTransport.UpdateBranchRule") @staticmethod def _get_response( @@ -2847,23 +10465,24 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: secure_source_manager.GetRepositoryRequest, + request: secure_source_manager.UpdateBranchRuleRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> secure_source_manager.Repository: - r"""Call the get repository method over HTTP. + ) -> operations_pb2.Operation: + r"""Call the update branch rule method over HTTP. Args: - request (~.secure_source_manager.GetRepositoryRequest): - The request object. GetRepositoryRequest is the request - for getting a repository. + request (~.secure_source_manager.UpdateBranchRuleRequest): + The request object. UpdateBranchRuleRequest is the + request to update a branchRule. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2873,23 +10492,30 @@ def __call__( be of type `bytes`. Returns: - ~.secure_source_manager.Repository: - Metadata of a Secure Source Manager - repository. + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseGetRepository._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule._get_http_options() ) - request, metadata = self._interceptor.pre_get_repository(request, metadata) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseGetRepository._get_transcoded_request( + request, metadata = self._interceptor.pre_update_branch_rule( + request, metadata + ) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule._get_transcoded_request( http_options, request ) + body = _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseGetRepository._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule._get_query_params_json( transcoded_request ) @@ -2901,7 +10527,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = type(request).to_json(request) + request_payload = json_format.MessageToJson(request) except: request_payload = None http_request = { @@ -2911,23 +10537,24 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.GetRepository", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.UpdateBranchRule", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "GetRepository", + "rpcName": "UpdateBranchRule", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._GetRepository._get_response( + response = SecureSourceManagerRestTransport._UpdateBranchRule._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2936,23 +10563,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = secure_source_manager.Repository() - pb_resp = secure_source_manager.Repository.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_repository(resp) + resp = self._interceptor.post_update_branch_rule(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_repository_with_metadata( + resp, _ = self._interceptor.post_update_branch_rule_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = secure_source_manager.Repository.to_json( - response - ) + response_payload = json_format.MessageToJson(resp) except: response_payload = None http_response = { @@ -2961,22 +10584,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_repository", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_branch_rule", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "GetRepository", + "rpcName": "UpdateBranchRule", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _ListBranchRules( - _BaseSecureSourceManagerRestTransport._BaseListBranchRules, + class _UpdateHook( + _BaseSecureSourceManagerRestTransport._BaseUpdateHook, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.ListBranchRules") + return hash("SecureSourceManagerRestTransport.UpdateHook") @staticmethod def _get_response( @@ -2997,23 +10620,24 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: secure_source_manager.ListBranchRulesRequest, + request: secure_source_manager.UpdateHookRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> secure_source_manager.ListBranchRulesResponse: - r"""Call the list branch rules method over HTTP. + ) -> operations_pb2.Operation: + r"""Call the update hook method over HTTP. Args: - request (~.secure_source_manager.ListBranchRulesRequest): - The request object. ListBranchRulesRequest is the request - to list branch rules. + request (~.secure_source_manager.UpdateHookRequest): + The request object. UpdateHookRequest is the request to + update a hook. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3023,25 +10647,28 @@ def __call__( be of type `bytes`. Returns: - ~.secure_source_manager.ListBranchRulesResponse: - ListBranchRulesResponse is the - response to listing branchRules. + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseListBranchRules._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseUpdateHook._get_http_options() ) - request, metadata = self._interceptor.pre_list_branch_rules( - request, metadata - ) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListBranchRules._get_transcoded_request( + request, metadata = self._interceptor.pre_update_hook(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseUpdateHook._get_transcoded_request( http_options, request ) + body = _BaseSecureSourceManagerRestTransport._BaseUpdateHook._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseListBranchRules._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseUpdateHook._get_query_params_json( transcoded_request ) @@ -3053,7 +10680,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = type(request).to_json(request) + request_payload = json_format.MessageToJson(request) except: request_payload = None http_request = { @@ -3063,23 +10690,24 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ListBranchRules", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.UpdateHook", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "ListBranchRules", + "rpcName": "UpdateHook", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._ListBranchRules._get_response( + response = SecureSourceManagerRestTransport._UpdateHook._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -3088,23 +10716,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = secure_source_manager.ListBranchRulesResponse() - pb_resp = secure_source_manager.ListBranchRulesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_branch_rules(resp) + resp = self._interceptor.post_update_hook(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_branch_rules_with_metadata( + resp, _ = self._interceptor.post_update_hook_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = ( - secure_source_manager.ListBranchRulesResponse.to_json(response) - ) + response_payload = json_format.MessageToJson(resp) except: response_payload = None http_response = { @@ -3113,22 +10737,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_branch_rules", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_hook", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "ListBranchRules", + "rpcName": "UpdateHook", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _ListInstances( - _BaseSecureSourceManagerRestTransport._BaseListInstances, + class _UpdateIssue( + _BaseSecureSourceManagerRestTransport._BaseUpdateIssue, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.ListInstances") + return hash("SecureSourceManagerRestTransport.UpdateIssue") @staticmethod def _get_response( @@ -3149,23 +10773,23 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: secure_source_manager.ListInstancesRequest, + request: secure_source_manager.UpdateIssueRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> secure_source_manager.ListInstancesResponse: - r"""Call the list instances method over HTTP. + ) -> operations_pb2.Operation: + r"""Call the update issue method over HTTP. Args: - request (~.secure_source_manager.ListInstancesRequest): - The request object. ListInstancesRequest is the request - to list instances. + request (~.secure_source_manager.UpdateIssueRequest): + The request object. The request to update an issue. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3175,21 +10799,28 @@ def __call__( be of type `bytes`. Returns: - ~.secure_source_manager.ListInstancesResponse: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseListInstances._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseUpdateIssue._get_http_options() + ) + + request, metadata = self._interceptor.pre_update_issue(request, metadata) + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseUpdateIssue._get_transcoded_request( + http_options, request ) - request, metadata = self._interceptor.pre_list_instances(request, metadata) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListInstances._get_transcoded_request( - http_options, request + body = _BaseSecureSourceManagerRestTransport._BaseUpdateIssue._get_request_body_json( + transcoded_request ) # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseListInstances._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseUpdateIssue._get_query_params_json( transcoded_request ) @@ -3201,7 +10832,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = type(request).to_json(request) + request_payload = json_format.MessageToJson(request) except: request_payload = None http_request = { @@ -3211,23 +10842,24 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ListInstances", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.UpdateIssue", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "ListInstances", + "rpcName": "UpdateIssue", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._ListInstances._get_response( + response = SecureSourceManagerRestTransport._UpdateIssue._get_response( self._host, metadata, query_params, self._session, timeout, transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -3236,23 +10868,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = secure_source_manager.ListInstancesResponse() - pb_resp = secure_source_manager.ListInstancesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_instances(resp) + resp = self._interceptor.post_update_issue(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_instances_with_metadata( + resp, _ = self._interceptor.post_update_issue_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = ( - secure_source_manager.ListInstancesResponse.to_json(response) - ) + response_payload = json_format.MessageToJson(resp) except: response_payload = None http_response = { @@ -3261,22 +10889,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_instances", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_issue", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "ListInstances", + "rpcName": "UpdateIssue", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _ListRepositories( - _BaseSecureSourceManagerRestTransport._BaseListRepositories, + class _UpdateIssueComment( + _BaseSecureSourceManagerRestTransport._BaseUpdateIssueComment, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.ListRepositories") + return hash("SecureSourceManagerRestTransport.UpdateIssueComment") @staticmethod def _get_response( @@ -3297,23 +10925,24 @@ def _get_response( timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, ) return response def __call__( self, - request: secure_source_manager.ListRepositoriesRequest, + request: secure_source_manager.UpdateIssueCommentRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> secure_source_manager.ListRepositoriesResponse: - r"""Call the list repositories method over HTTP. + ) -> operations_pb2.Operation: + r"""Call the update issue comment method over HTTP. Args: - request (~.secure_source_manager.ListRepositoriesRequest): - The request object. ListRepositoriesRequest is request to - list repositories. + request (~.secure_source_manager.UpdateIssueCommentRequest): + The request object. The request to update an issue + comment. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3323,23 +10952,30 @@ def __call__( be of type `bytes`. Returns: - ~.secure_source_manager.ListRepositoriesResponse: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseListRepositories._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseUpdateIssueComment._get_http_options() ) - request, metadata = self._interceptor.pre_list_repositories( + request, metadata = self._interceptor.pre_update_issue_comment( request, metadata ) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseListRepositories._get_transcoded_request( + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseUpdateIssueComment._get_transcoded_request( http_options, request ) + body = _BaseSecureSourceManagerRestTransport._BaseUpdateIssueComment._get_request_body_json( + transcoded_request + ) + # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseListRepositories._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseUpdateIssueComment._get_query_params_json( transcoded_request ) @@ -3351,7 +10987,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = type(request).to_json(request) + request_payload = json_format.MessageToJson(request) except: request_payload = None http_request = { @@ -3361,23 +10997,26 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.ListRepositories", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.UpdateIssueComment", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "ListRepositories", + "rpcName": "UpdateIssueComment", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._ListRepositories._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, + response = ( + SecureSourceManagerRestTransport._UpdateIssueComment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -3386,23 +11025,19 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = secure_source_manager.ListRepositoriesResponse() - pb_resp = secure_source_manager.ListRepositoriesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_repositories(resp) + resp = self._interceptor.post_update_issue_comment(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_repositories_with_metadata( + resp, _ = self._interceptor.post_update_issue_comment_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( logging.DEBUG ): # pragma: NO COVER try: - response_payload = ( - secure_source_manager.ListRepositoriesResponse.to_json(response) - ) + response_payload = json_format.MessageToJson(resp) except: response_payload = None http_response = { @@ -3411,22 +11046,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_repositories", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_issue_comment", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "ListRepositories", + "rpcName": "UpdateIssueComment", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _SetIamPolicyRepo( - _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo, + class _UpdatePullRequest( + _BaseSecureSourceManagerRestTransport._BaseUpdatePullRequest, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.SetIamPolicyRepo") + return hash("SecureSourceManagerRestTransport.UpdatePullRequest") @staticmethod def _get_response( @@ -3453,17 +11088,18 @@ def _get_response( def __call__( self, - request: iam_policy_pb2.SetIamPolicyRequest, + request: secure_source_manager.UpdatePullRequestRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> policy_pb2.Policy: - r"""Call the set iam policy repo method over HTTP. + ) -> operations_pb2.Operation: + r"""Call the update pull request method over HTTP. Args: - request (~.iam_policy_pb2.SetIamPolicyRequest): - The request object. Request message for ``SetIamPolicy`` method. + request (~.secure_source_manager.UpdatePullRequestRequest): + The request object. UpdatePullRequestRequest is the + request to update a pull request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3473,102 +11109,30 @@ def __call__( be of type `bytes`. Returns: - ~.policy_pb2.Policy: - An Identity and Access Management (IAM) policy, which - specifies access controls for Google Cloud resources. - - A ``Policy`` is a collection of ``bindings``. A - ``binding`` binds one or more ``members``, or - principals, to a single ``role``. Principals can be user - accounts, service accounts, Google groups, and domains - (such as G Suite). A ``role`` is a named list of - permissions; each ``role`` can be an IAM predefined role - or a user-created custom role. - - For some types of Google Cloud resources, a ``binding`` - can also specify a ``condition``, which is a logical - expression that allows access to a resource only if the - expression evaluates to ``true``. A condition can add - constraints based on attributes of the request, the - resource, or both. To learn which resources support - conditions in their IAM policies, see the `IAM - documentation `__. - - **JSON example:** - - :: - - { - "bindings": [ - { - "role": "roles/resourcemanager.organizationAdmin", - "members": [ - "user:mike@example.com", - "group:admins@example.com", - "domain:google.com", - "serviceAccount:my-project-id@appspot.gserviceaccount.com" - ] - }, - { - "role": "roles/resourcemanager.organizationViewer", - "members": [ - "user:eve@example.com" - ], - "condition": { - "title": "expirable access", - "description": "Does not grant access after Sep 2020", - "expression": "request.time < - timestamp('2020-10-01T00:00:00.000Z')", - } - } - ], - "etag": "BwWWja0YfJA=", - "version": 3 - } - - **YAML example:** - - :: - - bindings: - - members: - - user:mike@example.com - - group:admins@example.com - - domain:google.com - - serviceAccount:my-project-id@appspot.gserviceaccount.com - role: roles/resourcemanager.organizationAdmin - - members: - - user:eve@example.com - role: roles/resourcemanager.organizationViewer - condition: - title: expirable access - description: Does not grant access after Sep 2020 - expression: request.time < timestamp('2020-10-01T00:00:00.000Z') - etag: BwWWja0YfJA= - version: 3 - - For a description of IAM and its features, see the `IAM - documentation `__. + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseUpdatePullRequest._get_http_options() ) - request, metadata = self._interceptor.pre_set_iam_policy_repo( + request, metadata = self._interceptor.pre_update_pull_request( request, metadata ) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo._get_transcoded_request( + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseUpdatePullRequest._get_transcoded_request( http_options, request ) - body = _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo._get_request_body_json( + body = _BaseSecureSourceManagerRestTransport._BaseUpdatePullRequest._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseUpdatePullRequest._get_query_params_json( transcoded_request ) @@ -3590,24 +11154,26 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.SetIamPolicyRepo", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.UpdatePullRequest", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "SetIamPolicyRepo", + "rpcName": "UpdatePullRequest", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._SetIamPolicyRepo._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - body, + response = ( + SecureSourceManagerRestTransport._UpdatePullRequest._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -3616,14 +11182,12 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = policy_pb2.Policy() - pb_resp = resp - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_set_iam_policy_repo(resp) + resp = self._interceptor.post_update_pull_request(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_set_iam_policy_repo_with_metadata( + resp, _ = self._interceptor.post_update_pull_request_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -3639,22 +11203,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.set_iam_policy_repo", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_pull_request", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "SetIamPolicyRepo", + "rpcName": "UpdatePullRequest", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _TestIamPermissionsRepo( - _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo, + class _UpdatePullRequestComment( + _BaseSecureSourceManagerRestTransport._BaseUpdatePullRequestComment, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.TestIamPermissionsRepo") + return hash("SecureSourceManagerRestTransport.UpdatePullRequestComment") @staticmethod def _get_response( @@ -3681,47 +11245,52 @@ def _get_response( def __call__( self, - request: iam_policy_pb2.TestIamPermissionsRequest, + request: secure_source_manager.UpdatePullRequestCommentRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> iam_policy_pb2.TestIamPermissionsResponse: - r"""Call the test iam permissions repo method over HTTP. - - Args: - request (~.iam_policy_pb2.TestIamPermissionsRequest): - The request object. Request message for ``TestIamPermissions`` method. - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. + ) -> operations_pb2.Operation: + r"""Call the update pull request + comment method over HTTP. + + Args: + request (~.secure_source_manager.UpdatePullRequestCommentRequest): + The request object. The request to update a pull request + comment. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. - Returns: - ~.iam_policy_pb2.TestIamPermissionsResponse: - Response message for ``TestIamPermissions`` method. """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseUpdatePullRequestComment._get_http_options() ) - request, metadata = self._interceptor.pre_test_iam_permissions_repo( + request, metadata = self._interceptor.pre_update_pull_request_comment( request, metadata ) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo._get_transcoded_request( + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseUpdatePullRequestComment._get_transcoded_request( http_options, request ) - body = _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo._get_request_body_json( + body = _BaseSecureSourceManagerRestTransport._BaseUpdatePullRequestComment._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseUpdatePullRequestComment._get_query_params_json( transcoded_request ) @@ -3743,26 +11312,24 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.TestIamPermissionsRepo", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.UpdatePullRequestComment", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "TestIamPermissionsRepo", + "rpcName": "UpdatePullRequestComment", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = ( - SecureSourceManagerRestTransport._TestIamPermissionsRepo._get_response( - self._host, - metadata, - query_params, - self._session, - timeout, - transcoded_request, - body, - ) + response = SecureSourceManagerRestTransport._UpdatePullRequestComment._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -3771,14 +11338,12 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = iam_policy_pb2.TestIamPermissionsResponse() - pb_resp = resp - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_test_iam_permissions_repo(resp) + resp = self._interceptor.post_update_pull_request_comment(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_test_iam_permissions_repo_with_metadata( + resp, _ = self._interceptor.post_update_pull_request_comment_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -3794,22 +11359,22 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.test_iam_permissions_repo", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_pull_request_comment", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "TestIamPermissionsRepo", + "rpcName": "UpdatePullRequestComment", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp - class _UpdateBranchRule( - _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule, + class _UpdateRepository( + _BaseSecureSourceManagerRestTransport._BaseUpdateRepository, SecureSourceManagerRestStub, ): def __hash__(self): - return hash("SecureSourceManagerRestTransport.UpdateBranchRule") + return hash("SecureSourceManagerRestTransport.UpdateRepository") @staticmethod def _get_response( @@ -3836,18 +11401,18 @@ def _get_response( def __call__( self, - request: secure_source_manager.UpdateBranchRuleRequest, + request: secure_source_manager.UpdateRepositoryRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: - r"""Call the update branch rule method over HTTP. + r"""Call the update repository method over HTTP. Args: - request (~.secure_source_manager.UpdateBranchRuleRequest): - The request object. UpdateBranchRuleRequest is the - request to update a branchRule. + request (~.secure_source_manager.UpdateRepositoryRequest): + The request object. UpdateRepositoryRequest is the + request to update a repository. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -3865,22 +11430,22 @@ def __call__( """ http_options = ( - _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule._get_http_options() + _BaseSecureSourceManagerRestTransport._BaseUpdateRepository._get_http_options() ) - request, metadata = self._interceptor.pre_update_branch_rule( + request, metadata = self._interceptor.pre_update_repository( request, metadata ) - transcoded_request = _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule._get_transcoded_request( + transcoded_request = _BaseSecureSourceManagerRestTransport._BaseUpdateRepository._get_transcoded_request( http_options, request ) - body = _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule._get_request_body_json( + body = _BaseSecureSourceManagerRestTransport._BaseUpdateRepository._get_request_body_json( transcoded_request ) # Jsonify the query params - query_params = _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule._get_query_params_json( + query_params = _BaseSecureSourceManagerRestTransport._BaseUpdateRepository._get_query_params_json( transcoded_request ) @@ -3902,17 +11467,17 @@ def __call__( "headers": dict(metadata), } _LOGGER.debug( - f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.UpdateBranchRule", + f"Sending request for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.UpdateRepository", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "UpdateBranchRule", + "rpcName": "UpdateRepository", "httpRequest": http_request, "metadata": http_request["headers"], }, ) # Send the request - response = SecureSourceManagerRestTransport._UpdateBranchRule._get_response( + response = SecureSourceManagerRestTransport._UpdateRepository._get_response( self._host, metadata, query_params, @@ -3931,9 +11496,9 @@ def __call__( resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_branch_rule(resp) + resp = self._interceptor.post_update_repository(resp) response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_branch_rule_with_metadata( + resp, _ = self._interceptor.post_update_repository_with_metadata( resp, response_metadata ) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( @@ -3949,16 +11514,45 @@ def __call__( "status": response.status_code, } _LOGGER.debug( - "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_branch_rule", + "Received response for google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_repository", extra={ "serviceName": "google.cloud.securesourcemanager.v1.SecureSourceManager", - "rpcName": "UpdateBranchRule", + "rpcName": "UpdateRepository", "metadata": http_response["headers"], "httpResponse": http_response, }, ) return resp + @property + def batch_create_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.BatchCreatePullRequestCommentsRequest], + operations_pb2.Operation, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._BatchCreatePullRequestComments(self._session, self._host, self._interceptor) # type: ignore + + @property + def close_issue( + self, + ) -> Callable[[secure_source_manager.CloseIssueRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CloseIssue(self._session, self._host, self._interceptor) # type: ignore + + @property + def close_pull_request( + self, + ) -> Callable[ + [secure_source_manager.ClosePullRequestRequest], operations_pb2.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ClosePullRequest(self._session, self._host, self._interceptor) # type: ignore + @property def create_branch_rule( self, @@ -3969,6 +11563,14 @@ def create_branch_rule( # In C++ this would require a dynamic_cast return self._CreateBranchRule(self._session, self._host, self._interceptor) # type: ignore + @property + def create_hook( + self, + ) -> Callable[[secure_source_manager.CreateHookRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateHook(self._session, self._host, self._interceptor) # type: ignore + @property def create_instance( self, @@ -3979,6 +11581,45 @@ def create_instance( # In C++ this would require a dynamic_cast return self._CreateInstance(self._session, self._host, self._interceptor) # type: ignore + @property + def create_issue( + self, + ) -> Callable[[secure_source_manager.CreateIssueRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateIssue(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.CreateIssueCommentRequest], operations_pb2.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateIssueComment(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_pull_request( + self, + ) -> Callable[ + [secure_source_manager.CreatePullRequestRequest], operations_pb2.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreatePullRequest(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.CreatePullRequestCommentRequest], + operations_pb2.Operation, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreatePullRequestComment(self._session, self._host, self._interceptor) # type: ignore + @property def create_repository( self, @@ -3999,6 +11640,14 @@ def delete_branch_rule( # In C++ this would require a dynamic_cast return self._DeleteBranchRule(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_hook( + self, + ) -> Callable[[secure_source_manager.DeleteHookRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteHook(self._session, self._host, self._interceptor) # type: ignore + @property def delete_instance( self, @@ -4009,6 +11658,35 @@ def delete_instance( # In C++ this would require a dynamic_cast return self._DeleteInstance(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_issue( + self, + ) -> Callable[[secure_source_manager.DeleteIssueRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteIssue(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.DeleteIssueCommentRequest], operations_pb2.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteIssueComment(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.DeletePullRequestCommentRequest], + operations_pb2.Operation, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeletePullRequestComment(self._session, self._host, self._interceptor) # type: ignore + @property def delete_repository( self, @@ -4019,6 +11697,28 @@ def delete_repository( # In C++ this would require a dynamic_cast return self._DeleteRepository(self._session, self._host, self._interceptor) # type: ignore + @property + def fetch_blob( + self, + ) -> Callable[ + [secure_source_manager.FetchBlobRequest], + secure_source_manager.FetchBlobResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._FetchBlob(self._session, self._host, self._interceptor) # type: ignore + + @property + def fetch_tree( + self, + ) -> Callable[ + [secure_source_manager.FetchTreeRequest], + secure_source_manager.FetchTreeResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._FetchTree(self._session, self._host, self._interceptor) # type: ignore + @property def get_branch_rule( self, @@ -4029,6 +11729,14 @@ def get_branch_rule( # In C++ this would require a dynamic_cast return self._GetBranchRule(self._session, self._host, self._interceptor) # type: ignore + @property + def get_hook( + self, + ) -> Callable[[secure_source_manager.GetHookRequest], secure_source_manager.Hook]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetHook(self._session, self._host, self._interceptor) # type: ignore + @property def get_iam_policy_repo( self, @@ -4047,6 +11755,46 @@ def get_instance( # In C++ this would require a dynamic_cast return self._GetInstance(self._session, self._host, self._interceptor) # type: ignore + @property + def get_issue( + self, + ) -> Callable[[secure_source_manager.GetIssueRequest], secure_source_manager.Issue]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetIssue(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.GetIssueCommentRequest], + secure_source_manager.IssueComment, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetIssueComment(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_pull_request( + self, + ) -> Callable[ + [secure_source_manager.GetPullRequestRequest], secure_source_manager.PullRequest + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetPullRequest(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.GetPullRequestCommentRequest], + secure_source_manager.PullRequestComment, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetPullRequestComment(self._session, self._host, self._interceptor) # type: ignore + @property def get_repository( self, @@ -4068,6 +11816,17 @@ def list_branch_rules( # In C++ this would require a dynamic_cast return self._ListBranchRules(self._session, self._host, self._interceptor) # type: ignore + @property + def list_hooks( + self, + ) -> Callable[ + [secure_source_manager.ListHooksRequest], + secure_source_manager.ListHooksResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListHooks(self._session, self._host, self._interceptor) # type: ignore + @property def list_instances( self, @@ -4079,6 +11838,61 @@ def list_instances( # In C++ this would require a dynamic_cast return self._ListInstances(self._session, self._host, self._interceptor) # type: ignore + @property + def list_issue_comments( + self, + ) -> Callable[ + [secure_source_manager.ListIssueCommentsRequest], + secure_source_manager.ListIssueCommentsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListIssueComments(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_issues( + self, + ) -> Callable[ + [secure_source_manager.ListIssuesRequest], + secure_source_manager.ListIssuesResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListIssues(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.ListPullRequestCommentsRequest], + secure_source_manager.ListPullRequestCommentsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListPullRequestComments(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_pull_request_file_diffs( + self, + ) -> Callable[ + [secure_source_manager.ListPullRequestFileDiffsRequest], + secure_source_manager.ListPullRequestFileDiffsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListPullRequestFileDiffs(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_pull_requests( + self, + ) -> Callable[ + [secure_source_manager.ListPullRequestsRequest], + secure_source_manager.ListPullRequestsResponse, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListPullRequests(self._session, self._host, self._interceptor) # type: ignore + @property def list_repositories( self, @@ -4090,6 +11904,45 @@ def list_repositories( # In C++ this would require a dynamic_cast return self._ListRepositories(self._session, self._host, self._interceptor) # type: ignore + @property + def merge_pull_request( + self, + ) -> Callable[ + [secure_source_manager.MergePullRequestRequest], operations_pb2.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._MergePullRequest(self._session, self._host, self._interceptor) # type: ignore + + @property + def open_issue( + self, + ) -> Callable[[secure_source_manager.OpenIssueRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._OpenIssue(self._session, self._host, self._interceptor) # type: ignore + + @property + def open_pull_request( + self, + ) -> Callable[ + [secure_source_manager.OpenPullRequestRequest], operations_pb2.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._OpenPullRequest(self._session, self._host, self._interceptor) # type: ignore + + @property + def resolve_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.ResolvePullRequestCommentsRequest], + operations_pb2.Operation, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ResolvePullRequestComments(self._session, self._host, self._interceptor) # type: ignore + @property def set_iam_policy_repo( self, @@ -4109,6 +11962,17 @@ def test_iam_permissions_repo( # In C++ this would require a dynamic_cast return self._TestIamPermissionsRepo(self._session, self._host, self._interceptor) # type: ignore + @property + def unresolve_pull_request_comments( + self, + ) -> Callable[ + [secure_source_manager.UnresolvePullRequestCommentsRequest], + operations_pb2.Operation, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UnresolvePullRequestComments(self._session, self._host, self._interceptor) # type: ignore + @property def update_branch_rule( self, @@ -4119,6 +11983,63 @@ def update_branch_rule( # In C++ this would require a dynamic_cast return self._UpdateBranchRule(self._session, self._host, self._interceptor) # type: ignore + @property + def update_hook( + self, + ) -> Callable[[secure_source_manager.UpdateHookRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateHook(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_issue( + self, + ) -> Callable[[secure_source_manager.UpdateIssueRequest], operations_pb2.Operation]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateIssue(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_issue_comment( + self, + ) -> Callable[ + [secure_source_manager.UpdateIssueCommentRequest], operations_pb2.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateIssueComment(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_pull_request( + self, + ) -> Callable[ + [secure_source_manager.UpdatePullRequestRequest], operations_pb2.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdatePullRequest(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_pull_request_comment( + self, + ) -> Callable[ + [secure_source_manager.UpdatePullRequestCommentRequest], + operations_pb2.Operation, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdatePullRequestComment(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_repository( + self, + ) -> Callable[ + [secure_source_manager.UpdateRepositoryRequest], operations_pb2.Operation + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateRepository(self._session, self._host, self._interceptor) # type: ignore + @property def get_location(self): return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/rest_base.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/rest_base.py index 15fab818a845..848c69cb8732 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/rest_base.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/services/secure_source_manager/transports/rest_base.py @@ -91,13 +91,1833 @@ def __init__( api_audience=api_audience, ) + class _BaseBatchCreatePullRequestComments: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*/pullRequests/*}/pullRequestComments:batchCreate", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.BatchCreatePullRequestCommentsRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseBatchCreatePullRequestComments._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCloseIssue: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/issues/*}:close", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.CloseIssueRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseCloseIssue._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseClosePullRequest: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*}:close", + "body": "*", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.ClosePullRequestRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseClosePullRequest._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + class _BaseCreateBranchRule: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "branchRuleId": "", - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "branchRuleId": "", + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/branchRules", + "body": "branch_rule", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.CreateBranchRuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateHook: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "hookId": "", + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/hooks", + "body": "hook", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.CreateHookRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseCreateHook._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateInstance: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "instanceId": "", + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/instances", + "body": "instance", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.CreateInstanceRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseCreateInstance._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateIssue: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/issues", + "body": "issue", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.CreateIssueRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseCreateIssue._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateIssueComment: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*/issues/*}/issueComments", + "body": "issue_comment", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.CreateIssueCommentRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseCreateIssueComment._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreatePullRequest: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/pullRequests", + "body": "pull_request", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.CreatePullRequestRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseCreatePullRequest._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreatePullRequestComment: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*/pullRequests/*}/pullRequestComments", + "body": "pull_request_comment", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.CreatePullRequestCommentRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseCreatePullRequestComment._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateRepository: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "repositoryId": "", + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/repositories", + "body": "repository", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.CreateRepositoryRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseCreateRepository._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteBranchRule: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/branchRules/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.DeleteBranchRuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseDeleteBranchRule._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteHook: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/hooks/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.DeleteHookRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseDeleteHook._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteInstance: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/instances/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.DeleteInstanceRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseDeleteInstance._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteIssue: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/issues/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.DeleteIssueRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseDeleteIssue._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteIssueComment: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/issues/*/issueComments/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.DeleteIssueCommentRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseDeleteIssueComment._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeletePullRequestComment: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*/pullRequestComments/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.DeletePullRequestCommentRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseDeletePullRequestComment._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteRepository: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/repositories/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.DeleteRepositoryRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseDeleteRepository._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseFetchBlob: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "sha": "", + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{repository=projects/*/locations/*/repositories/*}:fetchBlob", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.FetchBlobRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseFetchBlob._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseFetchTree: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{repository=projects/*/locations/*/repositories/*}:fetchTree", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.FetchTreeRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseFetchTree._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetBranchRule: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/branchRules/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.GetBranchRuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseGetBranchRule._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetHook: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/hooks/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.GetHookRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseGetHook._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetIamPolicyRepo: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{resource=projects/*/locations/*/repositories/*}:getIamPolicy", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = request + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseGetIamPolicyRepo._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetInstance: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/instances/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.GetInstanceRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseGetInstance._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetIssue: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/issues/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.GetIssueRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseGetIssue._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetIssueComment: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/issues/*/issueComments/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.GetIssueCommentRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseGetIssueComment._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetPullRequest: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.GetPullRequestRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseGetPullRequest._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetPullRequestComment: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*/pullRequestComments/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.GetPullRequestCommentRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseGetPullRequestComment._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetRepository: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/repositories/*}", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.GetRepositoryRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseGetRepository._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListBranchRules: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/branchRules", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.ListBranchRulesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseListBranchRules._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListHooks: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/hooks", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.ListHooksRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseListHooks._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListInstances: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/instances", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.ListInstancesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseListInstances._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListIssueComments: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*/issues/*}/issueComments", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.ListIssueCommentsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseListIssueComments._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListIssues: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/issues", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.ListIssuesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseListIssues._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListPullRequestComments: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*/pullRequests/*}/pullRequestComments", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.ListPullRequestCommentsRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseListPullRequestComments._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListPullRequestFileDiffs: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*}:listFileDiffs", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = secure_source_manager.ListPullRequestFileDiffsRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseSecureSourceManagerRestTransport._BaseListPullRequestFileDiffs._get_unset_required_fields( + query_params + ) + ) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListPullRequests: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -111,28 +1931,18 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/branchRules", - "body": "branch_rule", + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/pullRequests", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.CreateBranchRuleRequest.pb(request) + pb_request = secure_source_manager.ListPullRequestsRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request["body"], use_integers_for_enums=True - ) - return body - @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -142,7 +1952,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseCreateBranchRule._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseListPullRequests._get_unset_required_fields( query_params ) ) @@ -150,13 +1960,11 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseCreateInstance: + class _BaseListRepositories: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "instanceId": "", - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -170,28 +1978,18 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/instances", - "body": "instance", + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/repositories", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.CreateInstanceRequest.pb(request) + pb_request = secure_source_manager.ListRepositoriesRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request - @staticmethod - def _get_request_body_json(transcoded_request): - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request["body"], use_integers_for_enums=True - ) - return body - @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -201,7 +1999,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseCreateInstance._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseListRepositories._get_unset_required_fields( query_params ) ) @@ -209,13 +2007,11 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseCreateRepository: + class _BaseMergePullRequest: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "repositoryId": "", - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -230,15 +2026,15 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/repositories", - "body": "repository", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*}:merge", + "body": "*", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.CreateRepositoryRequest.pb(request) + pb_request = secure_source_manager.MergePullRequestRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -260,7 +2056,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseCreateRepository._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseMergePullRequest._get_unset_required_fields( query_params ) ) @@ -268,7 +2064,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseDeleteBranchRule: + class _BaseOpenIssue: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -286,18 +2082,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "delete", - "uri": "/v1/{name=projects/*/locations/*/repositories/*/branchRules/*}", + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/issues/*}:open", + "body": "*", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.DeleteBranchRuleRequest.pb(request) + pb_request = secure_source_manager.OpenIssueRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -307,7 +2113,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseDeleteBranchRule._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseOpenIssue._get_unset_required_fields( query_params ) ) @@ -315,7 +2121,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseDeleteInstance: + class _BaseOpenPullRequest: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -333,18 +2139,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "delete", - "uri": "/v1/{name=projects/*/locations/*/instances/*}", + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*}:open", + "body": "*", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.DeleteInstanceRequest.pb(request) + pb_request = secure_source_manager.OpenPullRequestRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -354,7 +2170,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseDeleteInstance._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseOpenPullRequest._get_unset_required_fields( query_params ) ) @@ -362,7 +2178,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseDeleteRepository: + class _BaseResolvePullRequestComments: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -380,18 +2196,30 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "delete", - "uri": "/v1/{name=projects/*/locations/*/repositories/*}", + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*/pullRequests/*}/pullRequestComments:resolve", + "body": "*", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.DeleteRepositoryRequest.pb(request) + pb_request = secure_source_manager.ResolvePullRequestCommentsRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -401,7 +2229,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseDeleteRepository._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseResolvePullRequestComments._get_unset_required_fields( query_params ) ) @@ -409,7 +2237,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseGetBranchRule: + class _BaseSetIamPolicyRepo: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -427,18 +2255,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{name=projects/*/locations/*/repositories/*/branchRules/*}", + "method": "post", + "uri": "/v1/{resource=projects/*/locations/*/repositories/*}:setIamPolicy", + "body": "*", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.GetBranchRuleRequest.pb(request) + pb_request = request transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -448,7 +2286,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseGetBranchRule._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo._get_unset_required_fields( query_params ) ) @@ -456,7 +2294,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseGetIamPolicyRepo: + class _BaseTestIamPermissionsRepo: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -474,8 +2312,9 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{resource=projects/*/locations/*/repositories/*}:getIamPolicy", + "method": "post", + "uri": "/v1/{resource=projects/*/locations/*/repositories/*}:testIamPermissions", + "body": "*", }, ] return http_options @@ -486,6 +2325,15 @@ def _get_transcoded_request(http_options, request): transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -495,7 +2343,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseGetIamPolicyRepo._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo._get_unset_required_fields( query_params ) ) @@ -503,7 +2351,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseGetInstance: + class _BaseUnresolvePullRequestComments: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -521,18 +2369,30 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{name=projects/*/locations/*/instances/*}", + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*/repositories/*/pullRequests/*}/pullRequestComments:unresolve", + "body": "*", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.GetInstanceRequest.pb(request) + pb_request = secure_source_manager.UnresolvePullRequestCommentsRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -542,7 +2402,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseGetInstance._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseUnresolvePullRequestComments._get_unset_required_fields( query_params ) ) @@ -550,11 +2410,13 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseGetRepository: + class _BaseUpdateBranchRule: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "updateMask": {}, + } @classmethod def _get_unset_required_fields(cls, message_dict): @@ -568,18 +2430,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{name=projects/*/locations/*/repositories/*}", + "method": "patch", + "uri": "/v1/{branch_rule.name=projects/*/locations/*/repositories/*/branchRules/*}", + "body": "branch_rule", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.GetRepositoryRequest.pb(request) + pb_request = secure_source_manager.UpdateBranchRuleRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -589,7 +2461,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseGetRepository._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule._get_unset_required_fields( query_params ) ) @@ -597,11 +2469,13 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseListBranchRules: + class _BaseUpdateHook: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "updateMask": {}, + } @classmethod def _get_unset_required_fields(cls, message_dict): @@ -615,18 +2489,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{parent=projects/*/locations/*/repositories/*}/branchRules", + "method": "patch", + "uri": "/v1/{hook.name=projects/*/locations/*/repositories/*/hooks/*}", + "body": "hook", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.ListBranchRulesRequest.pb(request) + pb_request = secure_source_manager.UpdateHookRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -636,7 +2520,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseListBranchRules._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseUpdateHook._get_unset_required_fields( query_params ) ) @@ -644,7 +2528,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseListInstances: + class _BaseUpdateIssue: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -662,18 +2546,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{parent=projects/*/locations/*}/instances", + "method": "patch", + "uri": "/v1/{issue.name=projects/*/locations/*/repositories/*/issues/*}", + "body": "issue", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.ListInstancesRequest.pb(request) + pb_request = secure_source_manager.UpdateIssueRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -683,7 +2577,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseListInstances._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseUpdateIssue._get_unset_required_fields( query_params ) ) @@ -691,7 +2585,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseListRepositories: + class _BaseUpdateIssueComment: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -709,18 +2603,28 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "get", - "uri": "/v1/{parent=projects/*/locations/*}/repositories", + "method": "patch", + "uri": "/v1/{issue_comment.name=projects/*/locations/*/repositories/*/issues/*/issueComments/*}", + "body": "issue_comment", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.ListRepositoriesRequest.pb(request) + pb_request = secure_source_manager.UpdateIssueCommentRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], use_integers_for_enums=True + ) + return body + @staticmethod def _get_query_params_json(transcoded_request): query_params = json.loads( @@ -730,7 +2634,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseListRepositories._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseUpdateIssueComment._get_unset_required_fields( query_params ) ) @@ -738,7 +2642,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseSetIamPolicyRepo: + class _BaseUpdatePullRequest: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -756,16 +2660,16 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1/{resource=projects/*/locations/*/repositories/*}:setIamPolicy", - "body": "*", + "method": "patch", + "uri": "/v1/{pull_request.name=projects/*/locations/*/repositories/*/pullRequests/*}", + "body": "pull_request", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = request + pb_request = secure_source_manager.UpdatePullRequestRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -787,7 +2691,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseSetIamPolicyRepo._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseUpdatePullRequest._get_unset_required_fields( query_params ) ) @@ -795,7 +2699,7 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseTestIamPermissionsRepo: + class _BaseUpdatePullRequestComment: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") @@ -813,16 +2717,18 @@ def _get_unset_required_fields(cls, message_dict): def _get_http_options(): http_options: List[Dict[str, str]] = [ { - "method": "post", - "uri": "/v1/{resource=projects/*/locations/*/repositories/*}:testIamPermissions", - "body": "*", + "method": "patch", + "uri": "/v1/{pull_request_comment.name=projects/*/locations/*/repositories/*/pullRequests/*/pullRequestComments/*}", + "body": "pull_request_comment", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = request + pb_request = secure_source_manager.UpdatePullRequestCommentRequest.pb( + request + ) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -844,7 +2750,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseTestIamPermissionsRepo._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseUpdatePullRequestComment._get_unset_required_fields( query_params ) ) @@ -852,13 +2758,11 @@ def _get_query_params_json(transcoded_request): query_params["$alt"] = "json;enum-encoding=int" return query_params - class _BaseUpdateBranchRule: + class _BaseUpdateRepository: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "updateMask": {}, - } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -873,15 +2777,15 @@ def _get_http_options(): http_options: List[Dict[str, str]] = [ { "method": "patch", - "uri": "/v1/{branch_rule.name=projects/*/locations/*/repositories/*/branchRules/*}", - "body": "branch_rule", + "uri": "/v1/{repository.name=projects/*/locations/*/repositories/*}", + "body": "repository", }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): - pb_request = secure_source_manager.UpdateBranchRuleRequest.pb(request) + pb_request = secure_source_manager.UpdateRepositoryRequest.pb(request) transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -903,7 +2807,7 @@ def _get_query_params_json(transcoded_request): ) ) query_params.update( - _BaseSecureSourceManagerRestTransport._BaseUpdateBranchRule._get_unset_required_fields( + _BaseSecureSourceManagerRestTransport._BaseUpdateRepository._get_unset_required_fields( query_params ) ) diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/types/__init__.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/types/__init__.py index 4f99ac361bbb..e0b9c720bb74 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/types/__init__.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/types/__init__.py @@ -14,47 +14,155 @@ # limitations under the License. # from .secure_source_manager import ( + BatchCreatePullRequestCommentsRequest, + BatchCreatePullRequestCommentsResponse, BranchRule, + CloseIssueRequest, + ClosePullRequestRequest, CreateBranchRuleRequest, + CreateHookRequest, CreateInstanceRequest, + CreateIssueCommentRequest, + CreateIssueRequest, + CreatePullRequestCommentRequest, + CreatePullRequestRequest, CreateRepositoryRequest, DeleteBranchRuleRequest, + DeleteHookRequest, DeleteInstanceRequest, + DeleteIssueCommentRequest, + DeleteIssueRequest, + DeletePullRequestCommentRequest, DeleteRepositoryRequest, + FetchBlobRequest, + FetchBlobResponse, + FetchTreeRequest, + FetchTreeResponse, + FileDiff, GetBranchRuleRequest, + GetHookRequest, GetInstanceRequest, + GetIssueCommentRequest, + GetIssueRequest, + GetPullRequestCommentRequest, + GetPullRequestRequest, GetRepositoryRequest, + Hook, Instance, + Issue, + IssueComment, ListBranchRulesRequest, ListBranchRulesResponse, + ListHooksRequest, + ListHooksResponse, ListInstancesRequest, ListInstancesResponse, + ListIssueCommentsRequest, + ListIssueCommentsResponse, + ListIssuesRequest, + ListIssuesResponse, + ListPullRequestCommentsRequest, + ListPullRequestCommentsResponse, + ListPullRequestFileDiffsRequest, + ListPullRequestFileDiffsResponse, + ListPullRequestsRequest, + ListPullRequestsResponse, ListRepositoriesRequest, ListRepositoriesResponse, + MergePullRequestRequest, + OpenIssueRequest, + OpenPullRequestRequest, OperationMetadata, + PullRequest, + PullRequestComment, Repository, + ResolvePullRequestCommentsRequest, + ResolvePullRequestCommentsResponse, + TreeEntry, + UnresolvePullRequestCommentsRequest, + UnresolvePullRequestCommentsResponse, UpdateBranchRuleRequest, + UpdateHookRequest, + UpdateIssueCommentRequest, + UpdateIssueRequest, + UpdatePullRequestCommentRequest, + UpdatePullRequestRequest, + UpdateRepositoryRequest, ) __all__ = ( + "BatchCreatePullRequestCommentsRequest", + "BatchCreatePullRequestCommentsResponse", "BranchRule", + "CloseIssueRequest", + "ClosePullRequestRequest", "CreateBranchRuleRequest", + "CreateHookRequest", "CreateInstanceRequest", + "CreateIssueCommentRequest", + "CreateIssueRequest", + "CreatePullRequestCommentRequest", + "CreatePullRequestRequest", "CreateRepositoryRequest", "DeleteBranchRuleRequest", + "DeleteHookRequest", "DeleteInstanceRequest", + "DeleteIssueCommentRequest", + "DeleteIssueRequest", + "DeletePullRequestCommentRequest", "DeleteRepositoryRequest", + "FetchBlobRequest", + "FetchBlobResponse", + "FetchTreeRequest", + "FetchTreeResponse", + "FileDiff", "GetBranchRuleRequest", + "GetHookRequest", "GetInstanceRequest", + "GetIssueCommentRequest", + "GetIssueRequest", + "GetPullRequestCommentRequest", + "GetPullRequestRequest", "GetRepositoryRequest", + "Hook", "Instance", + "Issue", + "IssueComment", "ListBranchRulesRequest", "ListBranchRulesResponse", + "ListHooksRequest", + "ListHooksResponse", "ListInstancesRequest", "ListInstancesResponse", + "ListIssueCommentsRequest", + "ListIssueCommentsResponse", + "ListIssuesRequest", + "ListIssuesResponse", + "ListPullRequestCommentsRequest", + "ListPullRequestCommentsResponse", + "ListPullRequestFileDiffsRequest", + "ListPullRequestFileDiffsResponse", + "ListPullRequestsRequest", + "ListPullRequestsResponse", "ListRepositoriesRequest", "ListRepositoriesResponse", + "MergePullRequestRequest", + "OpenIssueRequest", + "OpenPullRequestRequest", "OperationMetadata", + "PullRequest", + "PullRequestComment", "Repository", + "ResolvePullRequestCommentsRequest", + "ResolvePullRequestCommentsResponse", + "TreeEntry", + "UnresolvePullRequestCommentsRequest", + "UnresolvePullRequestCommentsResponse", "UpdateBranchRuleRequest", + "UpdateHookRequest", + "UpdateIssueCommentRequest", + "UpdateIssueRequest", + "UpdatePullRequestCommentRequest", + "UpdatePullRequestRequest", + "UpdateRepositoryRequest", ) diff --git a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/types/secure_source_manager.py b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/types/secure_source_manager.py index 065c0d2c6e4d..76203d5ea58d 100644 --- a/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/types/secure_source_manager.py +++ b/packages/google-cloud-securesourcemanager/google/cloud/securesourcemanager_v1/types/secure_source_manager.py @@ -26,7 +26,13 @@ manifest={ "Instance", "Repository", + "Hook", "BranchRule", + "PullRequest", + "FileDiff", + "Issue", + "IssueComment", + "PullRequestComment", "ListInstancesRequest", "ListInstancesResponse", "GetInstanceRequest", @@ -37,13 +43,61 @@ "ListRepositoriesResponse", "GetRepositoryRequest", "CreateRepositoryRequest", + "UpdateRepositoryRequest", "DeleteRepositoryRequest", + "ListHooksRequest", + "ListHooksResponse", + "GetHookRequest", + "CreateHookRequest", + "UpdateHookRequest", + "DeleteHookRequest", "GetBranchRuleRequest", "CreateBranchRuleRequest", "ListBranchRulesRequest", "DeleteBranchRuleRequest", "UpdateBranchRuleRequest", "ListBranchRulesResponse", + "CreatePullRequestRequest", + "GetPullRequestRequest", + "ListPullRequestsRequest", + "ListPullRequestsResponse", + "UpdatePullRequestRequest", + "MergePullRequestRequest", + "OpenPullRequestRequest", + "ClosePullRequestRequest", + "ListPullRequestFileDiffsRequest", + "ListPullRequestFileDiffsResponse", + "CreateIssueRequest", + "GetIssueRequest", + "ListIssuesRequest", + "ListIssuesResponse", + "UpdateIssueRequest", + "DeleteIssueRequest", + "CloseIssueRequest", + "OpenIssueRequest", + "TreeEntry", + "FetchTreeRequest", + "FetchTreeResponse", + "FetchBlobRequest", + "FetchBlobResponse", + "ListPullRequestCommentsRequest", + "ListPullRequestCommentsResponse", + "CreatePullRequestCommentRequest", + "BatchCreatePullRequestCommentsRequest", + "BatchCreatePullRequestCommentsResponse", + "UpdatePullRequestCommentRequest", + "DeletePullRequestCommentRequest", + "GetPullRequestCommentRequest", + "ResolvePullRequestCommentsRequest", + "ResolvePullRequestCommentsResponse", + "UnresolvePullRequestCommentsRequest", + "UnresolvePullRequestCommentsResponse", + "CreateIssueCommentRequest", + "GetIssueCommentRequest", + "ListIssueCommentsRequest", + "ListIssueCommentsResponse", + "UpdateIssueCommentRequest", + "DeleteIssueCommentRequest", }, ) @@ -87,6 +141,11 @@ class Instance(proto.Message): host_config (google.cloud.securesourcemanager_v1.types.Instance.HostConfig): Output only. A list of hostnames for this instance. + workforce_identity_federation_config (google.cloud.securesourcemanager_v1.types.Instance.WorkforceIdentityFederationConfig): + Optional. Configuration for Workforce + Identity Federation to support third party + identity provider. If unset, defaults to the + Google OIDC IdP. """ class State(proto.Enum): @@ -138,8 +197,7 @@ class HostConfig(proto.Message): html (str): Output only. HTML hostname. api (str): - Output only. API hostname. This is the hostname to use for - **Host: Data Plane** endpoints. + Output only. API hostname. git_http (str): Output only. Git HTTP hostname. git_ssh (str): @@ -171,7 +229,7 @@ class PrivateConfig(proto.Message): Required. Immutable. Indicate if it's private instance. ca_pool (str): - Required. Immutable. CA pool resource, resource must in the + Optional. Immutable. CA pool resource, resource must in the format of ``projects/{project}/locations/{location}/caPools/{ca_pool}``. http_service_attachment (str): @@ -210,6 +268,21 @@ class PrivateConfig(proto.Message): number=6, ) + class WorkforceIdentityFederationConfig(proto.Message): + r"""WorkforceIdentityFederationConfig allows this instance to + support users from external identity providers. + + Attributes: + enabled (bool): + Optional. Immutable. Whether Workforce + Identity Federation is enabled. + """ + + enabled: bool = proto.Field( + proto.BOOL, + number=1, + ) + name: str = proto.Field( proto.STRING, number=1, @@ -253,6 +326,13 @@ class PrivateConfig(proto.Message): number=9, message=HostConfig, ) + workforce_identity_federation_config: WorkforceIdentityFederationConfig = ( + proto.Field( + proto.MESSAGE, + number=14, + message=WorkforceIdentityFederationConfig, + ) + ) class Repository(proto.Message): @@ -271,10 +351,9 @@ class Repository(proto.Message): is hosted, formatted as ``projects/{project_number}/locations/{location_id}/instances/{instance_id}`` When creating repository via - securesourcemanager.googleapis.com (Control Plane API), this - field is used as input. When creating repository via - \*.sourcemanager.dev (Data Plane API), this field is output - only. + securesourcemanager.googleapis.com, this field is used as + input. When creating repository via \*.sourcemanager.dev, + this field is output only. uid (str): Output only. Unique identifier of the repository. @@ -594,9 +673,113 @@ class InitialConfig(proto.Message): ) +class Hook(proto.Message): + r"""Metadata of a Secure Source Manager Hook. + + Attributes: + name (str): + Identifier. A unique identifier for a Hook. The name should + be of the format: + ``projects/{project}/locations/{location_id}/repositories/{repository_id}/hooks/{hook_id}`` + target_uri (str): + Required. The target URI to which the + payloads will be delivered. + disabled (bool): + Optional. Determines if the hook disabled or + not. Set to true to stop sending traffic. + events (MutableSequence[google.cloud.securesourcemanager_v1.types.Hook.HookEventType]): + Optional. The events that trigger hook on. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Create timestamp. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Update timestamp. + uid (str): + Output only. Unique identifier of the hook. + push_option (google.cloud.securesourcemanager_v1.types.Hook.PushOption): + Optional. The trigger option for push events. + sensitive_query_string (str): + Optional. The sensitive query string to be + appended to the target URI. + """ + + class HookEventType(proto.Enum): + r""" + + Values: + UNSPECIFIED (0): + Unspecified. + PUSH (1): + Push events are triggered when pushing to the + repository. + PULL_REQUEST (2): + Pull request events are triggered when a pull + request is opened, closed, reopened, or edited. + """ + UNSPECIFIED = 0 + PUSH = 1 + PULL_REQUEST = 2 + + class PushOption(proto.Message): + r""" + + Attributes: + branch_filter (str): + Optional. Trigger hook for matching branches only. Specified + as glob pattern. If empty or *, events for all branches are + reported. Examples: main, {main,release*}. See + https://pkg.go.dev/github.com/gobwas/glob documentation. + """ + + branch_filter: str = proto.Field( + proto.STRING, + number=1, + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + target_uri: str = proto.Field( + proto.STRING, + number=2, + ) + disabled: bool = proto.Field( + proto.BOOL, + number=3, + ) + events: MutableSequence[HookEventType] = proto.RepeatedField( + proto.ENUM, + number=4, + enum=HookEventType, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + uid: str = proto.Field( + proto.STRING, + number=7, + ) + push_option: PushOption = proto.Field( + proto.MESSAGE, + number=9, + message=PushOption, + ) + sensitive_query_string: str = proto.Field( + proto.STRING, + number=10, + ) + + class BranchRule(proto.Message): r"""Metadata of a BranchRule. BranchRule is the protection rule - to enforce pre-defined rules on desginated branches within a + to enforce pre-defined rules on designated branches within a repository. Attributes: @@ -732,142 +915,624 @@ class Check(proto.Message): ) -class ListInstancesRequest(proto.Message): - r"""ListInstancesRequest is the request to list instances. +class PullRequest(proto.Message): + r"""Metadata of a PullRequest. PullRequest is the request + from a user to merge a branch (head) into another branch (base). Attributes: - parent (str): - Required. Parent value for - ListInstancesRequest. - page_size (int): - Requested page size. Server may return fewer - items than requested. If unspecified, server - will pick an appropriate default. - page_token (str): - A token identifying a page of results the - server should return. - filter (str): - Filter for filtering results. - order_by (str): - Hint for how to order the results. + name (str): + Output only. A unique identifier for a PullRequest. The + number appended at the end is generated by the server. + Format: + ``projects/{project}/locations/{location}/repositories/{repository}/pullRequests/{pull_request_id}`` + title (str): + Required. The pull request title. + body (str): + Optional. The pull request body. Provides a + detailed description of the changes. + base (google.cloud.securesourcemanager_v1.types.PullRequest.Branch): + Required. The branch to merge changes in. + head (google.cloud.securesourcemanager_v1.types.PullRequest.Branch): + Immutable. The branch containing the changes + to be merged. + state (google.cloud.securesourcemanager_v1.types.PullRequest.State): + Output only. State of the pull request (open, + closed or merged). + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Creation timestamp. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Last updated timestamp. + close_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Close timestamp (if closed or + merged). Cleared when pull request is re-opened. """ - parent: str = proto.Field( + class State(proto.Enum): + r"""State of the pull request. + + Values: + STATE_UNSPECIFIED (0): + Unspecified. + OPEN (1): + An open pull request. + CLOSED (2): + A closed pull request. + MERGED (3): + A merged pull request. + """ + STATE_UNSPECIFIED = 0 + OPEN = 1 + CLOSED = 2 + MERGED = 3 + + class Branch(proto.Message): + r"""Branch represents a branch involved in a pull request. + + Attributes: + ref (str): + Required. Name of the branch. + sha (str): + Output only. The commit at the tip of the + branch. + """ + + ref: str = proto.Field( + proto.STRING, + number=1, + ) + sha: str = proto.Field( + proto.STRING, + number=2, + ) + + name: str = proto.Field( proto.STRING, number=1, ) - page_size: int = proto.Field( - proto.INT32, + title: str = proto.Field( + proto.STRING, number=2, ) - page_token: str = proto.Field( + body: str = proto.Field( proto.STRING, number=3, ) - filter: str = proto.Field( - proto.STRING, + base: Branch = proto.Field( + proto.MESSAGE, number=4, + message=Branch, ) - order_by: str = proto.Field( - proto.STRING, + head: Branch = proto.Field( + proto.MESSAGE, number=5, + message=Branch, + ) + state: State = proto.Field( + proto.ENUM, + number=6, + enum=State, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + close_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=9, + message=timestamp_pb2.Timestamp, ) -class ListInstancesResponse(proto.Message): - r""" +class FileDiff(proto.Message): + r"""Metadata of a FileDiff. FileDiff represents a single file + diff in a pull request. Attributes: - instances (MutableSequence[google.cloud.securesourcemanager_v1.types.Instance]): - The list of instances. - next_page_token (str): - A token identifying a page of results the - server should return. - unreachable (MutableSequence[str]): - Locations that could not be reached. + name (str): + Output only. The name of the file. + action (google.cloud.securesourcemanager_v1.types.FileDiff.Action): + Output only. The action taken on the file + (eg. added, modified, deleted). + sha (str): + Output only. The commit pointing to the file + changes. + patch (str): + Output only. The git patch containing the + file changes. """ - @property - def raw_page(self): - return self + class Action(proto.Enum): + r"""Action taken on the file. - instances: MutableSequence["Instance"] = proto.RepeatedField( - proto.MESSAGE, + Values: + ACTION_UNSPECIFIED (0): + Unspecified. + ADDED (1): + The file was added. + MODIFIED (2): + The file was modified. + DELETED (3): + The file was deleted. + """ + ACTION_UNSPECIFIED = 0 + ADDED = 1 + MODIFIED = 2 + DELETED = 3 + + name: str = proto.Field( + proto.STRING, number=1, - message="Instance", ) - next_page_token: str = proto.Field( - proto.STRING, + action: Action = proto.Field( + proto.ENUM, number=2, + enum=Action, ) - unreachable: MutableSequence[str] = proto.RepeatedField( + sha: str = proto.Field( proto.STRING, number=3, ) + patch: str = proto.Field( + proto.STRING, + number=4, + ) -class GetInstanceRequest(proto.Message): - r"""GetInstanceRequest is the request for getting an instance. +class Issue(proto.Message): + r"""Metadata of an Issue. Attributes: name (str): - Required. Name of the resource. + Identifier. Unique identifier for an issue. The issue id is + generated by the server. Format: + ``projects/{project}/locations/{location}/repositories/{repository}/issues/{issue_id}`` + title (str): + Required. Issue title. + body (str): + Optional. Issue body. Provides a detailed + description of the issue. + state (google.cloud.securesourcemanager_v1.types.Issue.State): + Output only. State of the issue. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Creation timestamp. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Last updated timestamp. + close_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Close timestamp (if closed). + Cleared when is re-opened. + etag (str): + Optional. This checksum is computed by the + server based on the value of other fields, and + may be sent on update and delete requests to + ensure the client has an up-to-date value before + proceeding. """ + class State(proto.Enum): + r"""Possible states of an issue. + + Values: + STATE_UNSPECIFIED (0): + Unspecified. + OPEN (1): + An open issue. + CLOSED (2): + A closed issue. + """ + STATE_UNSPECIFIED = 0 + OPEN = 1 + CLOSED = 2 + name: str = proto.Field( proto.STRING, number=1, ) + title: str = proto.Field( + proto.STRING, + number=2, + ) + body: str = proto.Field( + proto.STRING, + number=3, + ) + state: State = proto.Field( + proto.ENUM, + number=4, + enum=State, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + close_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + etag: str = proto.Field( + proto.STRING, + number=8, + ) -class CreateInstanceRequest(proto.Message): - r"""CreateInstanceRequest is the request for creating an - instance. +class IssueComment(proto.Message): + r"""IssueComment represents a comment on an issue. Attributes: - parent (str): - Required. Value for parent. - instance_id (str): - Required. ID of the instance to be created. - instance (google.cloud.securesourcemanager_v1.types.Instance): - Required. The resource being created. - request_id (str): - Optional. An optional request ID to identify - requests. Specify a unique request ID so that if - you must retry your request, the server will - know to ignore the request if it has already - been completed. The server will guarantee that - for at least 60 minutes since the first request. - - For example, consider a situation where you make - an initial request and the request times out. If - you make the request again with the same request - ID, the server can check if original operation - with the same request ID was received, and if - so, will ignore the second request. This - prevents clients from accidentally creating - duplicate commitments. - - The request ID must be a valid UUID with the - exception that zero UUID is not supported - (00000000-0000-0000-0000-000000000000). + name (str): + Identifier. Unique identifier for an issue comment. The + comment id is generated by the server. Format: + ``projects/{project}/locations/{location}/repositories/{repository}/issues/{issue}/issueComments/{comment_id}`` + body (str): + Required. The comment body. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Creation timestamp. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Last updated timestamp. """ - parent: str = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - instance_id: str = proto.Field( + body: str = proto.Field( proto.STRING, number=2, ) - instance: "Instance" = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=3, - message="Instance", + message=timestamp_pb2.Timestamp, ) - request_id: str = proto.Field( - proto.STRING, + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + + +class PullRequestComment(proto.Message): + r"""PullRequestComment represents a comment on a pull request. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + name (str): + Identifier. Unique identifier for the pull request comment. + The comment id is generated by the server. Format: + ``projects/{project}/locations/{location}/repositories/{repository}/pullRequests/{pull_request}/pullRequestComments/{comment_id}`` + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Creation timestamp. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Last updated timestamp. + review (google.cloud.securesourcemanager_v1.types.PullRequestComment.Review): + Optional. The review summary comment. + + This field is a member of `oneof`_ ``comment_detail``. + comment (google.cloud.securesourcemanager_v1.types.PullRequestComment.Comment): + Optional. The general pull request comment. + + This field is a member of `oneof`_ ``comment_detail``. + code (google.cloud.securesourcemanager_v1.types.PullRequestComment.Code): + Optional. The comment on a code line. + + This field is a member of `oneof`_ ``comment_detail``. + """ + + class Review(proto.Message): + r"""The review summary comment. + + Attributes: + action_type (google.cloud.securesourcemanager_v1.types.PullRequestComment.Review.ActionType): + Required. The review action type. + body (str): + Optional. The comment body. + effective_commit_sha (str): + Output only. The effective commit sha this + review is pointing to. + """ + + class ActionType(proto.Enum): + r"""The review action type. + + Values: + ACTION_TYPE_UNSPECIFIED (0): + Unspecified. + COMMENT (1): + A general review comment. + CHANGE_REQUESTED (2): + Change required from this review. + APPROVED (3): + Change approved from this review. + """ + ACTION_TYPE_UNSPECIFIED = 0 + COMMENT = 1 + CHANGE_REQUESTED = 2 + APPROVED = 3 + + action_type: "PullRequestComment.Review.ActionType" = proto.Field( + proto.ENUM, + number=1, + enum="PullRequestComment.Review.ActionType", + ) + body: str = proto.Field( + proto.STRING, + number=2, + ) + effective_commit_sha: str = proto.Field( + proto.STRING, + number=4, + ) + + class Comment(proto.Message): + r"""The general pull request comment. + + Attributes: + body (str): + Required. The comment body. + """ + + body: str = proto.Field( + proto.STRING, + number=1, + ) + + class Code(proto.Message): + r"""The comment on a code line. + + Attributes: + body (str): + Required. The comment body. + reply (str): + Optional. Input only. The PullRequestComment + resource name that this comment is replying to. + position (google.cloud.securesourcemanager_v1.types.PullRequestComment.Position): + Optional. The position of the comment. + effective_root_comment (str): + Output only. The root comment of the + conversation, derived from the reply field. + resolved (bool): + Output only. Boolean indicator if the comment + is resolved. + effective_commit_sha (str): + Output only. The effective commit sha this + code comment is pointing to. + """ + + body: str = proto.Field( + proto.STRING, + number=1, + ) + reply: str = proto.Field( + proto.STRING, + number=2, + ) + position: "PullRequestComment.Position" = proto.Field( + proto.MESSAGE, + number=3, + message="PullRequestComment.Position", + ) + effective_root_comment: str = proto.Field( + proto.STRING, + number=4, + ) + resolved: bool = proto.Field( + proto.BOOL, + number=5, + ) + effective_commit_sha: str = proto.Field( + proto.STRING, + number=7, + ) + + class Position(proto.Message): + r"""The position of the code comment. + + Attributes: + path (str): + Required. The path of the file. + line (int): + Required. The line number of the comment. + Positive value means it's on the new side of the + diff, negative value means it's on the old side. + """ + + path: str = proto.Field( + proto.STRING, + number=1, + ) + line: int = proto.Field( + proto.INT64, + number=2, + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + review: Review = proto.Field( + proto.MESSAGE, + number=4, + oneof="comment_detail", + message=Review, + ) + comment: Comment = proto.Field( + proto.MESSAGE, + number=5, + oneof="comment_detail", + message=Comment, + ) + code: Code = proto.Field( + proto.MESSAGE, + number=6, + oneof="comment_detail", + message=Code, + ) + + +class ListInstancesRequest(proto.Message): + r"""ListInstancesRequest is the request to list instances. + + Attributes: + parent (str): + Required. Parent value for + ListInstancesRequest. + page_size (int): + Requested page size. Server may return fewer + items than requested. If unspecified, server + will pick an appropriate default. + page_token (str): + A token identifying a page of results the + server should return. + filter (str): + Filter for filtering results. + order_by (str): + Hint for how to order the results. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListInstancesResponse(proto.Message): + r""" + + Attributes: + instances (MutableSequence[google.cloud.securesourcemanager_v1.types.Instance]): + The list of instances. + next_page_token (str): + A token identifying a page of results the + server should return. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + instances: MutableSequence["Instance"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Instance", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetInstanceRequest(proto.Message): + r"""GetInstanceRequest is the request for getting an instance. + + Attributes: + name (str): + Required. Name of the resource. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateInstanceRequest(proto.Message): + r"""CreateInstanceRequest is the request for creating an + instance. + + Attributes: + parent (str): + Required. Value for parent. + instance_id (str): + Required. ID of the instance to be created. + instance (google.cloud.securesourcemanager_v1.types.Instance): + Required. The resource being created. + request_id (str): + Optional. An optional request ID to identify + requests. Specify a unique request ID so that if + you must retry your request, the server will + know to ignore the request if it has already + been completed. The server will guarantee that + for at least 60 minutes since the first request. + + For example, consider a situation where you make + an initial request and the request times out. If + you make the request again with the same request + ID, the server can check if original operation + with the same request ID was received, and if + so, will ignore the second request. This + prevents clients from accidentally creating + duplicate commitments. + + The request ID must be a valid UUID with the + exception that zero UUID is not supported + (00000000-0000-0000-0000-000000000000). + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + instance_id: str = proto.Field( + proto.STRING, + number=2, + ) + instance: "Instance" = proto.Field( + proto.MESSAGE, + number=3, + message="Instance", + ) + request_id: str = proto.Field( + proto.STRING, number=4, ) @@ -933,7 +1598,8 @@ class OperationMetadata(proto.Message): requested_cancellation (bool): Output only. Identifies whether the user has requested cancellation of the operation. Operations that have - successfully been cancelled have [Operation.error][] value + successfully been cancelled have + [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to ``Code.CANCELLED``. api_version (str): @@ -995,10 +1661,9 @@ class ListRepositoriesRequest(proto.Message): is hosted, formatted as ``projects/{project_number}/locations/{location_id}/instances/{instance_id}``. When listing repositories via - securesourcemanager.googleapis.com (Control Plane API), this - field is required. When listing repositories via - \*.sourcemanager.dev (Data Plane API), this field is - ignored. + securesourcemanager.googleapis.com, this field is required. + When listing repositories via \*.sourcemanager.dev, this + field is ignored. """ parent: str = proto.Field( @@ -1097,6 +1762,43 @@ class CreateRepositoryRequest(proto.Message): ) +class UpdateRepositoryRequest(proto.Message): + r"""UpdateRepositoryRequest is the request to update a + repository. + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the repository resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be overwritten + if it is in the mask. If the user does not provide a mask + then all fields will be overwritten. + repository (google.cloud.securesourcemanager_v1.types.Repository): + Required. The repository being updated. + validate_only (bool): + Optional. False by default. If set to true, + the request is validated and the user is + provided with an expected result, but no actual + change is made. + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + repository: "Repository" = proto.Field( + proto.MESSAGE, + number=2, + message="Repository", + ) + validate_only: bool = proto.Field( + proto.BOOL, + number=3, + ) + + class DeleteRepositoryRequest(proto.Message): r"""DeleteRepositoryRequest is the request to delete a repository. @@ -1104,7 +1806,7 @@ class DeleteRepositoryRequest(proto.Message): Attributes: name (str): Required. Name of the repository to delete. The format is - projects/{project_number}/locations/{location_id}/repositories/{repository_id}. + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}``. allow_missing (bool): Optional. If set to true, and the repository is not found, the request will succeed but no @@ -1121,7 +1823,153 @@ class DeleteRepositoryRequest(proto.Message): ) -class GetBranchRuleRequest(proto.Message): +class ListHooksRequest(proto.Message): + r"""ListHooksRequest is request to list hooks. + + Attributes: + parent (str): + Required. Parent value for ListHooksRequest. + page_size (int): + Optional. Requested page size. Server may + return fewer items than requested. If + unspecified, server will pick an appropriate + default. + page_token (str): + Optional. A token identifying a page of + results the server should return. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListHooksResponse(proto.Message): + r"""ListHooksResponse is response to list hooks. + + Attributes: + hooks (MutableSequence[google.cloud.securesourcemanager_v1.types.Hook]): + The list of hooks. + next_page_token (str): + A token identifying a page of results the + server should return. + """ + + @property + def raw_page(self): + return self + + hooks: MutableSequence["Hook"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Hook", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetHookRequest(proto.Message): + r"""GetHookRequest is the request for getting a hook. + + Attributes: + name (str): + Required. Name of the hook to retrieve. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/hooks/{hook_id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateHookRequest(proto.Message): + r"""CreateHookRequest is the request for creating a hook. + + Attributes: + parent (str): + Required. The repository in which to create the hook. Values + are of the form + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + hook (google.cloud.securesourcemanager_v1.types.Hook): + Required. The resource being created. + hook_id (str): + Required. The ID to use for the hook, which + will become the final component of the hook's + resource name. This value restricts to + lower-case letters, numbers, and hyphen, with + the first character a letter, the last a letter + or a number, and a 63 character maximum. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + hook: "Hook" = proto.Field( + proto.MESSAGE, + number=2, + message="Hook", + ) + hook_id: str = proto.Field( + proto.STRING, + number=3, + ) + + +class UpdateHookRequest(proto.Message): + r"""UpdateHookRequest is the request to update a hook. + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the hook resource by the update. The fields + specified in the update_mask are relative to the resource, + not the full request. A field will be overwritten if it is + in the mask. The special value "*" means full replacement. + hook (google.cloud.securesourcemanager_v1.types.Hook): + Required. The hook being updated. + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + hook: "Hook" = proto.Field( + proto.MESSAGE, + number=2, + message="Hook", + ) + + +class DeleteHookRequest(proto.Message): + r"""DeleteHookRequest is the request to delete a hook. + + Attributes: + name (str): + Required. Name of the hook to delete. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/hooks/{hook_id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class GetBranchRuleRequest(proto.Message): r"""GetBranchRuleRequest is the request for getting a branch rule. @@ -1278,4 +2126,1043 @@ def raw_page(self): ) +class CreatePullRequestRequest(proto.Message): + r"""CreatePullRequestRequest is the request to create a pull + request. + + Attributes: + parent (str): + Required. The repository that the pull request is created + from. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + pull_request (google.cloud.securesourcemanager_v1.types.PullRequest): + Required. The pull request to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + pull_request: "PullRequest" = proto.Field( + proto.MESSAGE, + number=2, + message="PullRequest", + ) + + +class GetPullRequestRequest(proto.Message): + r"""GetPullRequestRequest is the request to get a pull request. + + Attributes: + name (str): + Required. Name of the pull request to retrieve. The format + is + ``projects/{project}/locations/{location}/repositories/{repository}/pullRequests/{pull_request}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListPullRequestsRequest(proto.Message): + r"""ListPullRequestsRequest is the request to list pull requests. + + Attributes: + parent (str): + Required. The repository in which to list pull requests. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + page_size (int): + Optional. Requested page size. Server may + return fewer items than requested. If + unspecified, server will pick an appropriate + default. + page_token (str): + Optional. A token identifying a page of + results the server should return. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListPullRequestsResponse(proto.Message): + r"""ListPullRequestsResponse is the response to list pull + requests. + + Attributes: + pull_requests (MutableSequence[google.cloud.securesourcemanager_v1.types.PullRequest]): + The list of pull requests. + next_page_token (str): + A token identifying a page of results the + server should return. + """ + + @property + def raw_page(self): + return self + + pull_requests: MutableSequence["PullRequest"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="PullRequest", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class UpdatePullRequestRequest(proto.Message): + r"""UpdatePullRequestRequest is the request to update a pull + request. + + Attributes: + pull_request (google.cloud.securesourcemanager_v1.types.PullRequest): + Required. The pull request to update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the pull request resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be overwritten + if it is in the mask. The special value "*" means full + replacement. + """ + + pull_request: "PullRequest" = proto.Field( + proto.MESSAGE, + number=1, + message="PullRequest", + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class MergePullRequestRequest(proto.Message): + r"""MergePullRequestRequest is the request to merge a pull + request. + + Attributes: + name (str): + Required. The pull request to merge. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class OpenPullRequestRequest(proto.Message): + r"""OpenPullRequestRequest is the request to open a pull request. + + Attributes: + name (str): + Required. The pull request to open. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ClosePullRequestRequest(proto.Message): + r"""ClosePullRequestRequest is the request to close a pull + request. + + Attributes: + name (str): + Required. The pull request to close. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListPullRequestFileDiffsRequest(proto.Message): + r"""ListPullRequestFileDiffsRequest is the request to list pull + request file diffs. + + Attributes: + name (str): + Required. The pull request to list file diffs for. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + page_size (int): + Optional. Requested page size. Server may + return fewer items than requested. If + unspecified, server will pick an appropriate + default. + page_token (str): + Optional. A token identifying a page of + results the server should return. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListPullRequestFileDiffsResponse(proto.Message): + r"""ListPullRequestFileDiffsResponse is the response containing + file diffs returned from ListPullRequestFileDiffs. + + Attributes: + file_diffs (MutableSequence[google.cloud.securesourcemanager_v1.types.FileDiff]): + The list of pull request file diffs. + next_page_token (str): + A token identifying a page of results the + server should return. + """ + + @property + def raw_page(self): + return self + + file_diffs: MutableSequence["FileDiff"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="FileDiff", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class CreateIssueRequest(proto.Message): + r"""The request to create an issue. + + Attributes: + parent (str): + Required. The repository in which to create the issue. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + issue (google.cloud.securesourcemanager_v1.types.Issue): + Required. The issue to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + issue: "Issue" = proto.Field( + proto.MESSAGE, + number=2, + message="Issue", + ) + + +class GetIssueRequest(proto.Message): + r"""The request to get an issue. + + Attributes: + name (str): + Required. Name of the issue to retrieve. The format is + ``projects/{project}/locations/{location}/repositories/{repository}/issues/{issue_id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListIssuesRequest(proto.Message): + r"""The request to list issues. + + Attributes: + parent (str): + Required. The repository in which to list issues. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}`` + page_size (int): + Optional. Requested page size. Server may + return fewer items than requested. If + unspecified, server will pick an appropriate + default. + page_token (str): + Optional. A token identifying a page of + results the server should return. + filter (str): + Optional. Used to filter the resulting issues + list. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + + +class ListIssuesResponse(proto.Message): + r"""The response to list issues. + + Attributes: + issues (MutableSequence[google.cloud.securesourcemanager_v1.types.Issue]): + The list of issues. + next_page_token (str): + A token identifying a page of results the + server should return. + """ + + @property + def raw_page(self): + return self + + issues: MutableSequence["Issue"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Issue", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class UpdateIssueRequest(proto.Message): + r"""The request to update an issue. + + Attributes: + issue (google.cloud.securesourcemanager_v1.types.Issue): + Required. The issue to update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the issue resource by the update. The fields + specified in the update_mask are relative to the resource, + not the full request. A field will be overwritten if it is + in the mask. The special value "*" means full replacement. + """ + + issue: "Issue" = proto.Field( + proto.MESSAGE, + number=1, + message="Issue", + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteIssueRequest(proto.Message): + r"""The request to delete an issue. + + Attributes: + name (str): + Required. Name of the issue to delete. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}``. + etag (str): + Optional. The current etag of the issue. + If the etag is provided and does not match the + current etag of the issue, deletion will be + blocked and an ABORTED error will be returned. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + etag: str = proto.Field( + proto.STRING, + number=2, + ) + + +class CloseIssueRequest(proto.Message): + r"""The request to close an issue. + + Attributes: + name (str): + Required. Name of the issue to close. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}``. + etag (str): + Optional. The current etag of the issue. + If the etag is provided and does not match the + current etag of the issue, closing will be + blocked and an ABORTED error will be returned. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + etag: str = proto.Field( + proto.STRING, + number=2, + ) + + +class OpenIssueRequest(proto.Message): + r"""The request to open an issue. + + Attributes: + name (str): + Required. Name of the issue to open. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}``. + etag (str): + Optional. The current etag of the issue. + If the etag is provided and does not match the + current etag of the issue, opening will be + blocked and an ABORTED error will be returned. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + etag: str = proto.Field( + proto.STRING, + number=2, + ) + + +class TreeEntry(proto.Message): + r"""Represents an entry within a tree structure (like a Git + tree). + + Attributes: + type_ (google.cloud.securesourcemanager_v1.types.TreeEntry.ObjectType): + Output only. The type of the object (TREE, + BLOB, COMMIT). Output-only. + sha (str): + Output only. The SHA-1 hash of the object + (unique identifier). Output-only. + path (str): + Output only. The path of the file or + directory within the tree (e.g., + "src/main/java/MyClass.java"). Output-only. + mode (str): + Output only. The file mode as a string (e.g., + "100644"). Indicates file type. Output-only. + size (int): + Output only. The size of the object in bytes + (only for blobs). Output-only. + """ + + class ObjectType(proto.Enum): + r"""Defines the type of object the TreeEntry represents. + + Values: + OBJECT_TYPE_UNSPECIFIED (0): + Default value, indicating the object type is + unspecified. + TREE (1): + Represents a directory (folder). + BLOB (2): + Represents a file (contains file data). + COMMIT (3): + Represents a pointer to another repository + (submodule). + """ + OBJECT_TYPE_UNSPECIFIED = 0 + TREE = 1 + BLOB = 2 + COMMIT = 3 + + type_: ObjectType = proto.Field( + proto.ENUM, + number=1, + enum=ObjectType, + ) + sha: str = proto.Field( + proto.STRING, + number=2, + ) + path: str = proto.Field( + proto.STRING, + number=3, + ) + mode: str = proto.Field( + proto.STRING, + number=4, + ) + size: int = proto.Field( + proto.INT64, + number=5, + ) + + +class FetchTreeRequest(proto.Message): + r"""Request message for fetching a tree structure from a + repository. + + Attributes: + repository (str): + Required. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}``. + Specifies the repository to fetch the tree from. + ref (str): + Optional. ``ref`` can be a SHA-1 hash, a branch name, or a + tag. Specifies which tree to fetch. If not specified, the + default branch will be used. + recursive (bool): + Optional. If true, include all subfolders and + their files in the response. If false, only the + immediate children are returned. + page_size (int): + Optional. Requested page size. Server may + return fewer items than requested. If + unspecified, at most 10,000 items will be + returned. + page_token (str): + Optional. A token identifying a page of + results the server should return. + """ + + repository: str = proto.Field( + proto.STRING, + number=1, + ) + ref: str = proto.Field( + proto.STRING, + number=2, + ) + recursive: bool = proto.Field( + proto.BOOL, + number=3, + ) + page_size: int = proto.Field( + proto.INT32, + number=4, + ) + page_token: str = proto.Field( + proto.STRING, + number=5, + ) + + +class FetchTreeResponse(proto.Message): + r"""Response message containing a list of TreeEntry objects. + + Attributes: + tree_entries (MutableSequence[google.cloud.securesourcemanager_v1.types.TreeEntry]): + The list of TreeEntry objects. + next_page_token (str): + A token identifying a page of results the + server should return. + """ + + @property + def raw_page(self): + return self + + tree_entries: MutableSequence["TreeEntry"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="TreeEntry", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class FetchBlobRequest(proto.Message): + r"""Request message for fetching a blob (file content) from a + repository. + + Attributes: + repository (str): + Required. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}``. + Specifies the repository containing the blob. + sha (str): + Required. The SHA-1 hash of the blob to + retrieve. + """ + + repository: str = proto.Field( + proto.STRING, + number=1, + ) + sha: str = proto.Field( + proto.STRING, + number=2, + ) + + +class FetchBlobResponse(proto.Message): + r"""Response message containing the content of a blob. + + Attributes: + sha (str): + The SHA-1 hash of the blob. + content (str): + The content of the blob, encoded as base64. + """ + + sha: str = proto.Field( + proto.STRING, + number=1, + ) + content: str = proto.Field( + proto.STRING, + number=2, + ) + + +class ListPullRequestCommentsRequest(proto.Message): + r"""The request to list pull request comments. + + Attributes: + parent (str): + Required. The pull request in which to list pull request + comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + page_size (int): + Optional. Requested page size. If + unspecified, at most 100 pull request comments + will be returned. The maximum value is 100; + values above 100 will be coerced to 100. + page_token (str): + Optional. A token identifying a page of + results the server should return. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListPullRequestCommentsResponse(proto.Message): + r"""The response to list pull request comments. + + Attributes: + pull_request_comments (MutableSequence[google.cloud.securesourcemanager_v1.types.PullRequestComment]): + The list of pull request comments. + next_page_token (str): + A token to set as page_token to retrieve the next page. If + this field is omitted, there are no subsequent pages. + """ + + @property + def raw_page(self): + return self + + pull_request_comments: MutableSequence["PullRequestComment"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="PullRequestComment", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class CreatePullRequestCommentRequest(proto.Message): + r"""The request to create a pull request comment. + + Attributes: + parent (str): + Required. The pull request in which to create the pull + request comment. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + pull_request_comment (google.cloud.securesourcemanager_v1.types.PullRequestComment): + Required. The pull request comment to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + pull_request_comment: "PullRequestComment" = proto.Field( + proto.MESSAGE, + number=2, + message="PullRequestComment", + ) + + +class BatchCreatePullRequestCommentsRequest(proto.Message): + r"""The request to batch create pull request comments. + + Attributes: + parent (str): + Required. The pull request in which to create the pull + request comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + requests (MutableSequence[google.cloud.securesourcemanager_v1.types.CreatePullRequestCommentRequest]): + Required. The request message specifying the + resources to create. There should be exactly one + CreatePullRequestCommentRequest with + CommentDetail being REVIEW in the list, and no + more than 100 CreatePullRequestCommentRequests + with CommentDetail being CODE in the list + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + requests: MutableSequence["CreatePullRequestCommentRequest"] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="CreatePullRequestCommentRequest", + ) + + +class BatchCreatePullRequestCommentsResponse(proto.Message): + r"""The response to batch create pull request comments. + + Attributes: + pull_request_comments (MutableSequence[google.cloud.securesourcemanager_v1.types.PullRequestComment]): + The list of pull request comments created. + """ + + pull_request_comments: MutableSequence["PullRequestComment"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="PullRequestComment", + ) + + +class UpdatePullRequestCommentRequest(proto.Message): + r"""The request to update a pull request comment. + + Attributes: + pull_request_comment (google.cloud.securesourcemanager_v1.types.PullRequestComment): + Required. The pull request comment to update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the pull request comment resource by the + update. Updatable fields are ``body``. + """ + + pull_request_comment: "PullRequestComment" = proto.Field( + proto.MESSAGE, + number=1, + message="PullRequestComment", + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeletePullRequestCommentRequest(proto.Message): + r"""The request to delete a pull request comment. A Review + PullRequestComment cannot be deleted. + + Attributes: + name (str): + Required. Name of the pull request comment to delete. The + format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}/pullRequestComments/{comment_id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class GetPullRequestCommentRequest(proto.Message): + r"""The request to get a pull request comment. + + Attributes: + name (str): + Required. Name of the pull request comment to retrieve. The + format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}/pullRequestComments/{comment_id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ResolvePullRequestCommentsRequest(proto.Message): + r"""The request to resolve multiple pull request comments. + + Attributes: + parent (str): + Required. The pull request in which to resolve the pull + request comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + names (MutableSequence[str]): + Required. The names of the pull request comments to resolve. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}/pullRequestComments/{comment_id}`` + Only comments from the same threads are allowed in the same + request. + auto_fill (bool): + Optional. If set, at least one comment in a + thread is required, rest of the comments in the + same thread will be automatically updated to + resolved. If unset, all comments in the same + thread need be present. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + names: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=2, + ) + auto_fill: bool = proto.Field( + proto.BOOL, + number=3, + ) + + +class ResolvePullRequestCommentsResponse(proto.Message): + r"""The response to resolve multiple pull request comments. + + Attributes: + pull_request_comments (MutableSequence[google.cloud.securesourcemanager_v1.types.PullRequestComment]): + The list of pull request comments resolved. + """ + + pull_request_comments: MutableSequence["PullRequestComment"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="PullRequestComment", + ) + + +class UnresolvePullRequestCommentsRequest(proto.Message): + r"""The request to unresolve multiple pull request comments. + + Attributes: + parent (str): + Required. The pull request in which to resolve the pull + request comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}`` + names (MutableSequence[str]): + Required. The names of the pull request comments to + unresolve. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/pullRequests/{pull_request_id}/pullRequestComments/{comment_id}`` + Only comments from the same threads are allowed in the same + request. + auto_fill (bool): + Optional. If set, at least one comment in a + thread is required, rest of the comments in the + same thread will be automatically updated to + unresolved. If unset, all comments in the same + thread need be present. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + names: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=2, + ) + auto_fill: bool = proto.Field( + proto.BOOL, + number=3, + ) + + +class UnresolvePullRequestCommentsResponse(proto.Message): + r"""The response to unresolve multiple pull request comments. + + Attributes: + pull_request_comments (MutableSequence[google.cloud.securesourcemanager_v1.types.PullRequestComment]): + The list of pull request comments unresolved. + """ + + pull_request_comments: MutableSequence["PullRequestComment"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="PullRequestComment", + ) + + +class CreateIssueCommentRequest(proto.Message): + r"""The request to create an issue comment. + + Attributes: + parent (str): + Required. The issue in which to create the issue comment. + Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}`` + issue_comment (google.cloud.securesourcemanager_v1.types.IssueComment): + Required. The issue comment to create. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + issue_comment: "IssueComment" = proto.Field( + proto.MESSAGE, + number=2, + message="IssueComment", + ) + + +class GetIssueCommentRequest(proto.Message): + r"""The request to get an issue comment. + + Attributes: + name (str): + Required. Name of the issue comment to retrieve. The format + is + ``projects/{project}/locations/{location}/repositories/{repository}/issues/{issue_id}/issueComments/{comment_id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListIssueCommentsRequest(proto.Message): + r"""The request to list issue comments. + + Attributes: + parent (str): + Required. The issue in which to list the comments. Format: + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}`` + page_size (int): + Optional. Requested page size. Server may + return fewer items than requested. If + unspecified, server will pick an appropriate + default. + page_token (str): + Optional. A token identifying a page of + results the server should return. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListIssueCommentsResponse(proto.Message): + r"""The response to list issue comments. + + Attributes: + issue_comments (MutableSequence[google.cloud.securesourcemanager_v1.types.IssueComment]): + The list of issue comments. + next_page_token (str): + A token identifying a page of results the + server should return. + """ + + @property + def raw_page(self): + return self + + issue_comments: MutableSequence["IssueComment"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="IssueComment", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class UpdateIssueCommentRequest(proto.Message): + r"""The request to update an issue comment. + + Attributes: + issue_comment (google.cloud.securesourcemanager_v1.types.IssueComment): + Required. The issue comment to update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. Field mask is used to specify the fields to be + overwritten in the issue comment resource by the update. The + fields specified in the update_mask are relative to the + resource, not the full request. A field will be overwritten + if it is in the mask. The special value "*" means full + replacement. + """ + + issue_comment: "IssueComment" = proto.Field( + proto.MESSAGE, + number=1, + message="IssueComment", + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteIssueCommentRequest(proto.Message): + r"""The request to delete an issue comment. + + Attributes: + name (str): + Required. Name of the issue comment to delete. The format is + ``projects/{project_number}/locations/{location_id}/repositories/{repository_id}/issues/{issue_id}/issueComments/{comment_id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_batch_create_pull_request_comments_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_batch_create_pull_request_comments_async.py new file mode 100644 index 000000000000..72a1a55cf720 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_batch_create_pull_request_comments_async.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchCreatePullRequestComments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_BatchCreatePullRequestComments_async] +# 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 import securesourcemanager_v1 + + +async def sample_batch_create_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + requests = securesourcemanager_v1.CreatePullRequestCommentRequest() + requests.parent = "parent_value" + requests.pull_request_comment.review.action_type = "APPROVED" + + request = securesourcemanager_v1.BatchCreatePullRequestCommentsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + operation = client.batch_create_pull_request_comments(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_BatchCreatePullRequestComments_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_batch_create_pull_request_comments_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_batch_create_pull_request_comments_sync.py new file mode 100644 index 000000000000..ad38fdefa6b4 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_batch_create_pull_request_comments_sync.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchCreatePullRequestComments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_BatchCreatePullRequestComments_sync] +# 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 import securesourcemanager_v1 + + +def sample_batch_create_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + requests = securesourcemanager_v1.CreatePullRequestCommentRequest() + requests.parent = "parent_value" + requests.pull_request_comment.review.action_type = "APPROVED" + + request = securesourcemanager_v1.BatchCreatePullRequestCommentsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + operation = client.batch_create_pull_request_comments(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_BatchCreatePullRequestComments_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_close_issue_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_close_issue_async.py new file mode 100644 index 000000000000..619803387f7b --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_close_issue_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CloseIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_CloseIssue_async] +# 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 import securesourcemanager_v1 + + +async def sample_close_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.CloseIssueRequest( + name="name_value", + ) + + # Make the request + operation = client.close_issue(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_CloseIssue_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_close_issue_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_close_issue_sync.py new file mode 100644 index 000000000000..e30f346770a6 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_close_issue_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CloseIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_CloseIssue_sync] +# 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 import securesourcemanager_v1 + + +def sample_close_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.CloseIssueRequest( + name="name_value", + ) + + # Make the request + operation = client.close_issue(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_CloseIssue_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_close_pull_request_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_close_pull_request_async.py new file mode 100644 index 000000000000..e9c25175ae93 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_close_pull_request_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ClosePullRequest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ClosePullRequest_async] +# 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 import securesourcemanager_v1 + + +async def sample_close_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ClosePullRequestRequest( + name="name_value", + ) + + # Make the request + operation = client.close_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ClosePullRequest_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_close_pull_request_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_close_pull_request_sync.py new file mode 100644 index 000000000000..27821bb15a67 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_close_pull_request_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ClosePullRequest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ClosePullRequest_sync] +# 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 import securesourcemanager_v1 + + +def sample_close_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ClosePullRequestRequest( + name="name_value", + ) + + # Make the request + operation = client.close_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ClosePullRequest_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_hook_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_hook_async.py new file mode 100644 index 000000000000..6d92b82a6d61 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_hook_async.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateHook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_CreateHook_async] +# 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 import securesourcemanager_v1 + + +async def sample_create_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + hook = securesourcemanager_v1.Hook() + hook.target_uri = "target_uri_value" + + request = securesourcemanager_v1.CreateHookRequest( + parent="parent_value", + hook=hook, + hook_id="hook_id_value", + ) + + # Make the request + operation = client.create_hook(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_CreateHook_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_hook_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_hook_sync.py new file mode 100644 index 000000000000..ee5b91b7546e --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_hook_sync.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateHook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_CreateHook_sync] +# 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 import securesourcemanager_v1 + + +def sample_create_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + hook = securesourcemanager_v1.Hook() + hook.target_uri = "target_uri_value" + + request = securesourcemanager_v1.CreateHookRequest( + parent="parent_value", + hook=hook, + hook_id="hook_id_value", + ) + + # Make the request + operation = client.create_hook(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_CreateHook_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_issue_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_issue_async.py new file mode 100644 index 000000000000..5e044a3e7cab --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_issue_async.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_CreateIssue_async] +# 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 import securesourcemanager_v1 + + +async def sample_create_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + issue = securesourcemanager_v1.Issue() + issue.title = "title_value" + + request = securesourcemanager_v1.CreateIssueRequest( + parent="parent_value", + issue=issue, + ) + + # Make the request + operation = client.create_issue(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_CreateIssue_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_issue_comment_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_issue_comment_async.py new file mode 100644 index 000000000000..a5ab1f248d92 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_issue_comment_async.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateIssueComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_CreateIssueComment_async] +# 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 import securesourcemanager_v1 + + +async def sample_create_issue_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + issue_comment = securesourcemanager_v1.IssueComment() + issue_comment.body = "body_value" + + request = securesourcemanager_v1.CreateIssueCommentRequest( + parent="parent_value", + issue_comment=issue_comment, + ) + + # Make the request + operation = client.create_issue_comment(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_CreateIssueComment_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_issue_comment_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_issue_comment_sync.py new file mode 100644 index 000000000000..1996dfe676db --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_issue_comment_sync.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateIssueComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_CreateIssueComment_sync] +# 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 import securesourcemanager_v1 + + +def sample_create_issue_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + issue_comment = securesourcemanager_v1.IssueComment() + issue_comment.body = "body_value" + + request = securesourcemanager_v1.CreateIssueCommentRequest( + parent="parent_value", + issue_comment=issue_comment, + ) + + # Make the request + operation = client.create_issue_comment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_CreateIssueComment_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_issue_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_issue_sync.py new file mode 100644 index 000000000000..ff1fbcb784cf --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_issue_sync.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_CreateIssue_sync] +# 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 import securesourcemanager_v1 + + +def sample_create_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + issue = securesourcemanager_v1.Issue() + issue.title = "title_value" + + request = securesourcemanager_v1.CreateIssueRequest( + parent="parent_value", + issue=issue, + ) + + # Make the request + operation = client.create_issue(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_CreateIssue_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_pull_request_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_pull_request_async.py new file mode 100644 index 000000000000..03c43748f050 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_pull_request_async.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreatePullRequest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_CreatePullRequest_async] +# 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 import securesourcemanager_v1 + + +async def sample_create_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + pull_request = securesourcemanager_v1.PullRequest() + pull_request.title = "title_value" + pull_request.base.ref = "ref_value" + + request = securesourcemanager_v1.CreatePullRequestRequest( + parent="parent_value", + pull_request=pull_request, + ) + + # Make the request + operation = client.create_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_CreatePullRequest_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_pull_request_comment_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_pull_request_comment_async.py new file mode 100644 index 000000000000..cc69d338961c --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_pull_request_comment_async.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreatePullRequestComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_CreatePullRequestComment_async] +# 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 import securesourcemanager_v1 + + +async def sample_create_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + pull_request_comment = securesourcemanager_v1.PullRequestComment() + pull_request_comment.review.action_type = "APPROVED" + + request = securesourcemanager_v1.CreatePullRequestCommentRequest( + parent="parent_value", + pull_request_comment=pull_request_comment, + ) + + # Make the request + operation = client.create_pull_request_comment(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_CreatePullRequestComment_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_pull_request_comment_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_pull_request_comment_sync.py new file mode 100644 index 000000000000..d984977a1867 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_pull_request_comment_sync.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreatePullRequestComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_CreatePullRequestComment_sync] +# 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 import securesourcemanager_v1 + + +def sample_create_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + pull_request_comment = securesourcemanager_v1.PullRequestComment() + pull_request_comment.review.action_type = "APPROVED" + + request = securesourcemanager_v1.CreatePullRequestCommentRequest( + parent="parent_value", + pull_request_comment=pull_request_comment, + ) + + # Make the request + operation = client.create_pull_request_comment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_CreatePullRequestComment_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_pull_request_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_pull_request_sync.py new file mode 100644 index 000000000000..9435b3f7b715 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_create_pull_request_sync.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreatePullRequest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_CreatePullRequest_sync] +# 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 import securesourcemanager_v1 + + +def sample_create_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + pull_request = securesourcemanager_v1.PullRequest() + pull_request.title = "title_value" + pull_request.base.ref = "ref_value" + + request = securesourcemanager_v1.CreatePullRequestRequest( + parent="parent_value", + pull_request=pull_request, + ) + + # Make the request + operation = client.create_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_CreatePullRequest_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_hook_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_hook_async.py new file mode 100644 index 000000000000..708957db7594 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_hook_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteHook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_DeleteHook_async] +# 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 import securesourcemanager_v1 + + +async def sample_delete_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeleteHookRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_hook(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_DeleteHook_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_hook_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_hook_sync.py new file mode 100644 index 000000000000..f2092e0ed720 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_hook_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteHook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_DeleteHook_sync] +# 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 import securesourcemanager_v1 + + +def sample_delete_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeleteHookRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_hook(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_DeleteHook_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_issue_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_issue_async.py new file mode 100644 index 000000000000..fcdd67b88179 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_issue_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_DeleteIssue_async] +# 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 import securesourcemanager_v1 + + +async def sample_delete_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeleteIssueRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_issue(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_DeleteIssue_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_issue_comment_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_issue_comment_async.py new file mode 100644 index 000000000000..bd59c1e9f7bc --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_issue_comment_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteIssueComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_DeleteIssueComment_async] +# 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 import securesourcemanager_v1 + + +async def sample_delete_issue_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeleteIssueCommentRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_issue_comment(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_DeleteIssueComment_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_issue_comment_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_issue_comment_sync.py new file mode 100644 index 000000000000..c3f47fd21664 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_issue_comment_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteIssueComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_DeleteIssueComment_sync] +# 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 import securesourcemanager_v1 + + +def sample_delete_issue_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeleteIssueCommentRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_issue_comment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_DeleteIssueComment_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_issue_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_issue_sync.py new file mode 100644 index 000000000000..a3505d903101 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_issue_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_DeleteIssue_sync] +# 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 import securesourcemanager_v1 + + +def sample_delete_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeleteIssueRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_issue(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_DeleteIssue_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_pull_request_comment_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_pull_request_comment_async.py new file mode 100644 index 000000000000..7c202e068a7e --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_pull_request_comment_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeletePullRequestComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_DeletePullRequestComment_async] +# 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 import securesourcemanager_v1 + + +async def sample_delete_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeletePullRequestCommentRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_pull_request_comment(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_DeletePullRequestComment_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_pull_request_comment_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_pull_request_comment_sync.py new file mode 100644 index 000000000000..e9f7c207fa32 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_delete_pull_request_comment_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeletePullRequestComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_DeletePullRequestComment_sync] +# 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 import securesourcemanager_v1 + + +def sample_delete_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.DeletePullRequestCommentRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_pull_request_comment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_DeletePullRequestComment_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_fetch_blob_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_fetch_blob_async.py new file mode 100644 index 000000000000..d1e1257039c4 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_fetch_blob_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for FetchBlob +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_FetchBlob_async] +# 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 import securesourcemanager_v1 + + +async def sample_fetch_blob(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.FetchBlobRequest( + repository="repository_value", + sha="sha_value", + ) + + # Make the request + response = await client.fetch_blob(request=request) + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_FetchBlob_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_fetch_blob_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_fetch_blob_sync.py new file mode 100644 index 000000000000..15d284e1b428 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_fetch_blob_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for FetchBlob +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_FetchBlob_sync] +# 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 import securesourcemanager_v1 + + +def sample_fetch_blob(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.FetchBlobRequest( + repository="repository_value", + sha="sha_value", + ) + + # Make the request + response = client.fetch_blob(request=request) + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_FetchBlob_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_fetch_tree_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_fetch_tree_async.py new file mode 100644 index 000000000000..a4dec36520a7 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_fetch_tree_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for FetchTree +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_FetchTree_async] +# 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 import securesourcemanager_v1 + + +async def sample_fetch_tree(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.FetchTreeRequest( + repository="repository_value", + ) + + # Make the request + page_result = client.fetch_tree(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_FetchTree_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_fetch_tree_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_fetch_tree_sync.py new file mode 100644 index 000000000000..7ef3037d4496 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_fetch_tree_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for FetchTree +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_FetchTree_sync] +# 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 import securesourcemanager_v1 + + +def sample_fetch_tree(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.FetchTreeRequest( + repository="repository_value", + ) + + # Make the request + page_result = client.fetch_tree(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_FetchTree_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_hook_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_hook_async.py new file mode 100644 index 000000000000..deb27ab57549 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_hook_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetHook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_GetHook_async] +# 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 import securesourcemanager_v1 + + +async def sample_get_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetHookRequest( + name="name_value", + ) + + # Make the request + response = await client.get_hook(request=request) + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_GetHook_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_hook_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_hook_sync.py new file mode 100644 index 000000000000..d5cbe444d0d8 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_hook_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetHook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_GetHook_sync] +# 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 import securesourcemanager_v1 + + +def sample_get_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetHookRequest( + name="name_value", + ) + + # Make the request + response = client.get_hook(request=request) + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_GetHook_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_issue_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_issue_async.py new file mode 100644 index 000000000000..44ccc9304058 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_issue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_GetIssue_async] +# 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 import securesourcemanager_v1 + + +async def sample_get_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetIssueRequest( + name="name_value", + ) + + # Make the request + response = await client.get_issue(request=request) + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_GetIssue_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_issue_comment_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_issue_comment_async.py new file mode 100644 index 000000000000..a5f2a95e9a7e --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_issue_comment_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIssueComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_GetIssueComment_async] +# 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 import securesourcemanager_v1 + + +async def sample_get_issue_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetIssueCommentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_issue_comment(request=request) + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_GetIssueComment_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_issue_comment_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_issue_comment_sync.py new file mode 100644 index 000000000000..e8c5d9388844 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_issue_comment_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIssueComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_GetIssueComment_sync] +# 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 import securesourcemanager_v1 + + +def sample_get_issue_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetIssueCommentRequest( + name="name_value", + ) + + # Make the request + response = client.get_issue_comment(request=request) + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_GetIssueComment_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_issue_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_issue_sync.py new file mode 100644 index 000000000000..fe2b8abe21b1 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_issue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_GetIssue_sync] +# 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 import securesourcemanager_v1 + + +def sample_get_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetIssueRequest( + name="name_value", + ) + + # Make the request + response = client.get_issue(request=request) + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_GetIssue_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_pull_request_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_pull_request_async.py new file mode 100644 index 000000000000..a72f33db27d8 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_pull_request_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetPullRequest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_GetPullRequest_async] +# 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 import securesourcemanager_v1 + + +async def sample_get_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetPullRequestRequest( + name="name_value", + ) + + # Make the request + response = await client.get_pull_request(request=request) + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_GetPullRequest_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_pull_request_comment_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_pull_request_comment_async.py new file mode 100644 index 000000000000..27c728d80b01 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_pull_request_comment_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetPullRequestComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_GetPullRequestComment_async] +# 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 import securesourcemanager_v1 + + +async def sample_get_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetPullRequestCommentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_pull_request_comment(request=request) + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_GetPullRequestComment_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_pull_request_comment_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_pull_request_comment_sync.py new file mode 100644 index 000000000000..8c96f0ba8574 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_pull_request_comment_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetPullRequestComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_GetPullRequestComment_sync] +# 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 import securesourcemanager_v1 + + +def sample_get_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetPullRequestCommentRequest( + name="name_value", + ) + + # Make the request + response = client.get_pull_request_comment(request=request) + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_GetPullRequestComment_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_pull_request_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_pull_request_sync.py new file mode 100644 index 000000000000..b4ef7443ef69 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_get_pull_request_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetPullRequest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_GetPullRequest_sync] +# 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 import securesourcemanager_v1 + + +def sample_get_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.GetPullRequestRequest( + name="name_value", + ) + + # Make the request + response = client.get_pull_request(request=request) + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_GetPullRequest_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_hooks_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_hooks_async.py new file mode 100644 index 000000000000..3b390a368282 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_hooks_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListHooks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ListHooks_async] +# 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 import securesourcemanager_v1 + + +async def sample_list_hooks(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListHooksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_hooks(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ListHooks_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_hooks_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_hooks_sync.py new file mode 100644 index 000000000000..9290404f39c3 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_hooks_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListHooks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ListHooks_sync] +# 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 import securesourcemanager_v1 + + +def sample_list_hooks(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListHooksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_hooks(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ListHooks_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_issue_comments_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_issue_comments_async.py new file mode 100644 index 000000000000..3d2a5658ef22 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_issue_comments_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListIssueComments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ListIssueComments_async] +# 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 import securesourcemanager_v1 + + +async def sample_list_issue_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListIssueCommentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_issue_comments(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ListIssueComments_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_issue_comments_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_issue_comments_sync.py new file mode 100644 index 000000000000..d3245b41316e --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_issue_comments_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListIssueComments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ListIssueComments_sync] +# 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 import securesourcemanager_v1 + + +def sample_list_issue_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListIssueCommentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_issue_comments(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ListIssueComments_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_issues_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_issues_async.py new file mode 100644 index 000000000000..d5cbc9a0d0b1 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_issues_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListIssues +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ListIssues_async] +# 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 import securesourcemanager_v1 + + +async def sample_list_issues(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListIssuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_issues(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ListIssues_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_issues_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_issues_sync.py new file mode 100644 index 000000000000..cdb860a3373d --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_issues_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListIssues +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ListIssues_sync] +# 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 import securesourcemanager_v1 + + +def sample_list_issues(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListIssuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_issues(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ListIssues_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_request_comments_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_request_comments_async.py new file mode 100644 index 000000000000..1ed32432dcf3 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_request_comments_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPullRequestComments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ListPullRequestComments_async] +# 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 import securesourcemanager_v1 + + +async def sample_list_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListPullRequestCommentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pull_request_comments(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ListPullRequestComments_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_request_comments_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_request_comments_sync.py new file mode 100644 index 000000000000..de79e51efc59 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_request_comments_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPullRequestComments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ListPullRequestComments_sync] +# 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 import securesourcemanager_v1 + + +def sample_list_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListPullRequestCommentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pull_request_comments(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ListPullRequestComments_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_request_file_diffs_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_request_file_diffs_async.py new file mode 100644 index 000000000000..3933b920b04b --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_request_file_diffs_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPullRequestFileDiffs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ListPullRequestFileDiffs_async] +# 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 import securesourcemanager_v1 + + +async def sample_list_pull_request_file_diffs(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListPullRequestFileDiffsRequest( + name="name_value", + ) + + # Make the request + page_result = client.list_pull_request_file_diffs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ListPullRequestFileDiffs_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_request_file_diffs_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_request_file_diffs_sync.py new file mode 100644 index 000000000000..0c48f59de8fe --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_request_file_diffs_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPullRequestFileDiffs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ListPullRequestFileDiffs_sync] +# 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 import securesourcemanager_v1 + + +def sample_list_pull_request_file_diffs(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListPullRequestFileDiffsRequest( + name="name_value", + ) + + # Make the request + page_result = client.list_pull_request_file_diffs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ListPullRequestFileDiffs_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_requests_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_requests_async.py new file mode 100644 index 000000000000..fbd0d3db03af --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_requests_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPullRequests +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ListPullRequests_async] +# 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 import securesourcemanager_v1 + + +async def sample_list_pull_requests(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListPullRequestsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pull_requests(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ListPullRequests_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_requests_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_requests_sync.py new file mode 100644 index 000000000000..33725dd10c98 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_list_pull_requests_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPullRequests +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ListPullRequests_sync] +# 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 import securesourcemanager_v1 + + +def sample_list_pull_requests(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ListPullRequestsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pull_requests(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ListPullRequests_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_merge_pull_request_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_merge_pull_request_async.py new file mode 100644 index 000000000000..ee51f6827919 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_merge_pull_request_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for MergePullRequest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_MergePullRequest_async] +# 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 import securesourcemanager_v1 + + +async def sample_merge_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.MergePullRequestRequest( + name="name_value", + ) + + # Make the request + operation = client.merge_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_MergePullRequest_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_merge_pull_request_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_merge_pull_request_sync.py new file mode 100644 index 000000000000..b8a45d451010 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_merge_pull_request_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for MergePullRequest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_MergePullRequest_sync] +# 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 import securesourcemanager_v1 + + +def sample_merge_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.MergePullRequestRequest( + name="name_value", + ) + + # Make the request + operation = client.merge_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_MergePullRequest_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_open_issue_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_open_issue_async.py new file mode 100644 index 000000000000..ae79eac6d375 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_open_issue_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for OpenIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_OpenIssue_async] +# 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 import securesourcemanager_v1 + + +async def sample_open_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.OpenIssueRequest( + name="name_value", + ) + + # Make the request + operation = client.open_issue(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_OpenIssue_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_open_issue_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_open_issue_sync.py new file mode 100644 index 000000000000..cdcd0df053ee --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_open_issue_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for OpenIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_OpenIssue_sync] +# 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 import securesourcemanager_v1 + + +def sample_open_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.OpenIssueRequest( + name="name_value", + ) + + # Make the request + operation = client.open_issue(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_OpenIssue_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_open_pull_request_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_open_pull_request_async.py new file mode 100644 index 000000000000..7508e2f20a8e --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_open_pull_request_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for OpenPullRequest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_OpenPullRequest_async] +# 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 import securesourcemanager_v1 + + +async def sample_open_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.OpenPullRequestRequest( + name="name_value", + ) + + # Make the request + operation = client.open_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_OpenPullRequest_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_open_pull_request_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_open_pull_request_sync.py new file mode 100644 index 000000000000..c4224cb26602 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_open_pull_request_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for OpenPullRequest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_OpenPullRequest_sync] +# 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 import securesourcemanager_v1 + + +def sample_open_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.OpenPullRequestRequest( + name="name_value", + ) + + # Make the request + operation = client.open_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_OpenPullRequest_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_resolve_pull_request_comments_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_resolve_pull_request_comments_async.py new file mode 100644 index 000000000000..c62cb7711548 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_resolve_pull_request_comments_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ResolvePullRequestComments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ResolvePullRequestComments_async] +# 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 import securesourcemanager_v1 + + +async def sample_resolve_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ResolvePullRequestCommentsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], + ) + + # Make the request + operation = client.resolve_pull_request_comments(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ResolvePullRequestComments_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_resolve_pull_request_comments_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_resolve_pull_request_comments_sync.py new file mode 100644 index 000000000000..3cffcf91ca2a --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_resolve_pull_request_comments_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ResolvePullRequestComments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_ResolvePullRequestComments_sync] +# 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 import securesourcemanager_v1 + + +def sample_resolve_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.ResolvePullRequestCommentsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], + ) + + # Make the request + operation = client.resolve_pull_request_comments(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_ResolvePullRequestComments_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_unresolve_pull_request_comments_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_unresolve_pull_request_comments_async.py new file mode 100644 index 000000000000..428a4a6ff4b5 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_unresolve_pull_request_comments_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UnresolvePullRequestComments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UnresolvePullRequestComments_async] +# 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 import securesourcemanager_v1 + + +async def sample_unresolve_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.UnresolvePullRequestCommentsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], + ) + + # Make the request + operation = client.unresolve_pull_request_comments(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UnresolvePullRequestComments_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_unresolve_pull_request_comments_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_unresolve_pull_request_comments_sync.py new file mode 100644 index 000000000000..2dfef8ab9c47 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_unresolve_pull_request_comments_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UnresolvePullRequestComments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UnresolvePullRequestComments_sync] +# 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 import securesourcemanager_v1 + + +def sample_unresolve_pull_request_comments(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.UnresolvePullRequestCommentsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], + ) + + # Make the request + operation = client.unresolve_pull_request_comments(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UnresolvePullRequestComments_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_hook_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_hook_async.py new file mode 100644 index 000000000000..c1ca1c5f0b23 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_hook_async.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateHook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UpdateHook_async] +# 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 import securesourcemanager_v1 + + +async def sample_update_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + hook = securesourcemanager_v1.Hook() + hook.target_uri = "target_uri_value" + + request = securesourcemanager_v1.UpdateHookRequest( + hook=hook, + ) + + # Make the request + operation = client.update_hook(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UpdateHook_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_hook_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_hook_sync.py new file mode 100644 index 000000000000..1fc3fe08b6f9 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_hook_sync.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateHook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UpdateHook_sync] +# 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 import securesourcemanager_v1 + + +def sample_update_hook(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + hook = securesourcemanager_v1.Hook() + hook.target_uri = "target_uri_value" + + request = securesourcemanager_v1.UpdateHookRequest( + hook=hook, + ) + + # Make the request + operation = client.update_hook(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UpdateHook_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_issue_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_issue_async.py new file mode 100644 index 000000000000..0a29e67997a6 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_issue_async.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UpdateIssue_async] +# 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 import securesourcemanager_v1 + + +async def sample_update_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + issue = securesourcemanager_v1.Issue() + issue.title = "title_value" + + request = securesourcemanager_v1.UpdateIssueRequest( + issue=issue, + ) + + # Make the request + operation = client.update_issue(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UpdateIssue_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_issue_comment_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_issue_comment_async.py new file mode 100644 index 000000000000..b2cd9295da09 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_issue_comment_async.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateIssueComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UpdateIssueComment_async] +# 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 import securesourcemanager_v1 + + +async def sample_update_issue_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + issue_comment = securesourcemanager_v1.IssueComment() + issue_comment.body = "body_value" + + request = securesourcemanager_v1.UpdateIssueCommentRequest( + issue_comment=issue_comment, + ) + + # Make the request + operation = client.update_issue_comment(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UpdateIssueComment_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_issue_comment_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_issue_comment_sync.py new file mode 100644 index 000000000000..707f1db181fe --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_issue_comment_sync.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateIssueComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UpdateIssueComment_sync] +# 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 import securesourcemanager_v1 + + +def sample_update_issue_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + issue_comment = securesourcemanager_v1.IssueComment() + issue_comment.body = "body_value" + + request = securesourcemanager_v1.UpdateIssueCommentRequest( + issue_comment=issue_comment, + ) + + # Make the request + operation = client.update_issue_comment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UpdateIssueComment_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_issue_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_issue_sync.py new file mode 100644 index 000000000000..69a6a684783d --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_issue_sync.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateIssue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UpdateIssue_sync] +# 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 import securesourcemanager_v1 + + +def sample_update_issue(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + issue = securesourcemanager_v1.Issue() + issue.title = "title_value" + + request = securesourcemanager_v1.UpdateIssueRequest( + issue=issue, + ) + + # Make the request + operation = client.update_issue(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UpdateIssue_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_pull_request_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_pull_request_async.py new file mode 100644 index 000000000000..e70004199d71 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_pull_request_async.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdatePullRequest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UpdatePullRequest_async] +# 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 import securesourcemanager_v1 + + +async def sample_update_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + pull_request = securesourcemanager_v1.PullRequest() + pull_request.title = "title_value" + pull_request.base.ref = "ref_value" + + request = securesourcemanager_v1.UpdatePullRequestRequest( + pull_request=pull_request, + ) + + # Make the request + operation = client.update_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UpdatePullRequest_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_pull_request_comment_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_pull_request_comment_async.py new file mode 100644 index 000000000000..78a7a0e91437 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_pull_request_comment_async.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdatePullRequestComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UpdatePullRequestComment_async] +# 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 import securesourcemanager_v1 + + +async def sample_update_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + pull_request_comment = securesourcemanager_v1.PullRequestComment() + pull_request_comment.review.action_type = "APPROVED" + + request = securesourcemanager_v1.UpdatePullRequestCommentRequest( + pull_request_comment=pull_request_comment, + ) + + # Make the request + operation = client.update_pull_request_comment(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UpdatePullRequestComment_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_pull_request_comment_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_pull_request_comment_sync.py new file mode 100644 index 000000000000..926b0d7b85f9 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_pull_request_comment_sync.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdatePullRequestComment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UpdatePullRequestComment_sync] +# 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 import securesourcemanager_v1 + + +def sample_update_pull_request_comment(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + pull_request_comment = securesourcemanager_v1.PullRequestComment() + pull_request_comment.review.action_type = "APPROVED" + + request = securesourcemanager_v1.UpdatePullRequestCommentRequest( + pull_request_comment=pull_request_comment, + ) + + # Make the request + operation = client.update_pull_request_comment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UpdatePullRequestComment_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_pull_request_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_pull_request_sync.py new file mode 100644 index 000000000000..5205533d62fb --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_pull_request_sync.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdatePullRequest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UpdatePullRequest_sync] +# 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 import securesourcemanager_v1 + + +def sample_update_pull_request(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + pull_request = securesourcemanager_v1.PullRequest() + pull_request.title = "title_value" + pull_request.base.ref = "ref_value" + + request = securesourcemanager_v1.UpdatePullRequestRequest( + pull_request=pull_request, + ) + + # Make the request + operation = client.update_pull_request(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UpdatePullRequest_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_repository_async.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_repository_async.py new file mode 100644 index 000000000000..b1ebf2e88bbe --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_repository_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateRepository +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UpdateRepository_async] +# 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 import securesourcemanager_v1 + + +async def sample_update_repository(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerAsyncClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.UpdateRepositoryRequest( + ) + + # Make the request + operation = client.update_repository(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UpdateRepository_async] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_repository_sync.py b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_repository_sync.py new file mode 100644 index 000000000000..91c10ff5fb17 --- /dev/null +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/securesourcemanager_v1_generated_secure_source_manager_update_repository_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateRepository +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-securesourcemanager + + +# [START securesourcemanager_v1_generated_SecureSourceManager_UpdateRepository_sync] +# 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 import securesourcemanager_v1 + + +def sample_update_repository(): + # Create a client + client = securesourcemanager_v1.SecureSourceManagerClient() + + # Initialize request argument(s) + request = securesourcemanager_v1.UpdateRepositoryRequest( + ) + + # Make the request + operation = client.update_repository(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END securesourcemanager_v1_generated_SecureSourceManager_UpdateRepository_sync] diff --git a/packages/google-cloud-securesourcemanager/samples/generated_samples/snippet_metadata_google.cloud.securesourcemanager.v1.json b/packages/google-cloud-securesourcemanager/samples/generated_samples/snippet_metadata_google.cloud.securesourcemanager.v1.json index 61b28fdc2e03..38b2d04e321f 100644 --- a/packages/google-cloud-securesourcemanager/samples/generated_samples/snippet_metadata_google.cloud.securesourcemanager.v1.json +++ b/packages/google-cloud-securesourcemanager/samples/generated_samples/snippet_metadata_google.cloud.securesourcemanager.v1.json @@ -19,31 +19,27 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.create_branch_rule", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.batch_create_pull_request_comments", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateBranchRule", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.BatchCreatePullRequestComments", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "CreateBranchRule" + "shortName": "BatchCreatePullRequestComments" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.CreateBranchRuleRequest" + "type": "google.cloud.securesourcemanager_v1.types.BatchCreatePullRequestCommentsRequest" }, { "name": "parent", "type": "str" }, { - "name": "branch_rule", - "type": "google.cloud.securesourcemanager_v1.types.BranchRule" - }, - { - "name": "branch_rule_id", - "type": "str" + "name": "requests", + "type": "MutableSequence[google.cloud.securesourcemanager_v1.types.CreatePullRequestCommentRequest]" }, { "name": "retry", @@ -59,21 +55,21 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_branch_rule" + "shortName": "batch_create_pull_request_comments" }, - "description": "Sample for CreateBranchRule", - "file": "securesourcemanager_v1_generated_secure_source_manager_create_branch_rule_async.py", + "description": "Sample for BatchCreatePullRequestComments", + "file": "securesourcemanager_v1_generated_secure_source_manager_batch_create_pull_request_comments_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateBranchRule_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_BatchCreatePullRequestComments_async", "segments": [ { - "end": 56, + "end": 60, "start": 27, "type": "FULL" }, { - "end": 56, + "end": 60, "start": 27, "type": "SHORT" }, @@ -83,22 +79,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 53, - "start": 47, + "end": 57, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 57, - "start": 54, + "end": 61, + "start": 58, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_create_branch_rule_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_batch_create_pull_request_comments_async.py" }, { "canonical": true, @@ -107,31 +103,27 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_branch_rule", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.batch_create_pull_request_comments", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateBranchRule", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.BatchCreatePullRequestComments", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "CreateBranchRule" + "shortName": "BatchCreatePullRequestComments" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.CreateBranchRuleRequest" + "type": "google.cloud.securesourcemanager_v1.types.BatchCreatePullRequestCommentsRequest" }, { "name": "parent", "type": "str" }, { - "name": "branch_rule", - "type": "google.cloud.securesourcemanager_v1.types.BranchRule" - }, - { - "name": "branch_rule_id", - "type": "str" + "name": "requests", + "type": "MutableSequence[google.cloud.securesourcemanager_v1.types.CreatePullRequestCommentRequest]" }, { "name": "retry", @@ -147,21 +139,21 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "create_branch_rule" + "shortName": "batch_create_pull_request_comments" }, - "description": "Sample for CreateBranchRule", - "file": "securesourcemanager_v1_generated_secure_source_manager_create_branch_rule_sync.py", + "description": "Sample for BatchCreatePullRequestComments", + "file": "securesourcemanager_v1_generated_secure_source_manager_batch_create_pull_request_comments_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateBranchRule_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_BatchCreatePullRequestComments_sync", "segments": [ { - "end": 56, + "end": 60, "start": 27, "type": "FULL" }, { - "end": 56, + "end": 60, "start": 27, "type": "SHORT" }, @@ -171,22 +163,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 53, - "start": 47, + "end": 57, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 57, - "start": 54, + "end": 61, + "start": 58, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_create_branch_rule_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_batch_create_pull_request_comments_sync.py" }, { "canonical": true, @@ -196,30 +188,22 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.create_instance", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.close_issue", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateInstance", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CloseIssue", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "CreateInstance" + "shortName": "CloseIssue" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.CreateInstanceRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "instance", - "type": "google.cloud.securesourcemanager_v1.types.Instance" + "type": "google.cloud.securesourcemanager_v1.types.CloseIssueRequest" }, { - "name": "instance_id", + "name": "name", "type": "str" }, { @@ -236,21 +220,21 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_instance" + "shortName": "close_issue" }, - "description": "Sample for CreateInstance", - "file": "securesourcemanager_v1_generated_secure_source_manager_create_instance_async.py", + "description": "Sample for CloseIssue", + "file": "securesourcemanager_v1_generated_secure_source_manager_close_issue_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateInstance_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CloseIssue_async", "segments": [ { - "end": 56, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 56, + "end": 55, "start": 27, "type": "SHORT" }, @@ -260,22 +244,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 53, - "start": 47, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 57, - "start": 54, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_create_instance_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_close_issue_async.py" }, { "canonical": true, @@ -284,30 +268,22 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_instance", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.close_issue", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateInstance", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CloseIssue", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "CreateInstance" + "shortName": "CloseIssue" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.CreateInstanceRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "instance", - "type": "google.cloud.securesourcemanager_v1.types.Instance" + "type": "google.cloud.securesourcemanager_v1.types.CloseIssueRequest" }, { - "name": "instance_id", + "name": "name", "type": "str" }, { @@ -324,21 +300,21 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "create_instance" + "shortName": "close_issue" }, - "description": "Sample for CreateInstance", - "file": "securesourcemanager_v1_generated_secure_source_manager_create_instance_sync.py", + "description": "Sample for CloseIssue", + "file": "securesourcemanager_v1_generated_secure_source_manager_close_issue_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateInstance_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CloseIssue_sync", "segments": [ { - "end": 56, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 56, + "end": 55, "start": 27, "type": "SHORT" }, @@ -348,22 +324,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 53, - "start": 47, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 57, - "start": 54, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_create_instance_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_close_issue_sync.py" }, { "canonical": true, @@ -373,30 +349,22 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.create_repository", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.close_pull_request", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateRepository", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ClosePullRequest", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "CreateRepository" + "shortName": "ClosePullRequest" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.CreateRepositoryRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "repository", - "type": "google.cloud.securesourcemanager_v1.types.Repository" + "type": "google.cloud.securesourcemanager_v1.types.ClosePullRequestRequest" }, { - "name": "repository_id", + "name": "name", "type": "str" }, { @@ -413,21 +381,21 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_repository" + "shortName": "close_pull_request" }, - "description": "Sample for CreateRepository", - "file": "securesourcemanager_v1_generated_secure_source_manager_create_repository_async.py", + "description": "Sample for ClosePullRequest", + "file": "securesourcemanager_v1_generated_secure_source_manager_close_pull_request_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateRepository_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ClosePullRequest_async", "segments": [ { - "end": 56, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 56, + "end": 55, "start": 27, "type": "SHORT" }, @@ -437,22 +405,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 53, - "start": 47, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 57, - "start": 54, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_create_repository_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_close_pull_request_async.py" }, { "canonical": true, @@ -461,30 +429,22 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_repository", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.close_pull_request", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateRepository", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ClosePullRequest", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "CreateRepository" + "shortName": "ClosePullRequest" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.CreateRepositoryRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "repository", - "type": "google.cloud.securesourcemanager_v1.types.Repository" + "type": "google.cloud.securesourcemanager_v1.types.ClosePullRequestRequest" }, { - "name": "repository_id", + "name": "name", "type": "str" }, { @@ -501,21 +461,21 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "create_repository" + "shortName": "close_pull_request" }, - "description": "Sample for CreateRepository", - "file": "securesourcemanager_v1_generated_secure_source_manager_create_repository_sync.py", + "description": "Sample for ClosePullRequest", + "file": "securesourcemanager_v1_generated_secure_source_manager_close_pull_request_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateRepository_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ClosePullRequest_sync", "segments": [ { - "end": 56, + "end": 55, "start": 27, "type": "FULL" }, { - "end": 56, + "end": 55, "start": 27, "type": "SHORT" }, @@ -525,22 +485,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 53, - "start": 47, + "end": 52, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 57, - "start": 54, + "end": 56, + "start": 53, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_create_repository_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_close_pull_request_sync.py" }, { "canonical": true, @@ -550,22 +510,30 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.delete_branch_rule", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.create_branch_rule", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteBranchRule", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateBranchRule", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "DeleteBranchRule" + "shortName": "CreateBranchRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.DeleteBranchRuleRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreateBranchRuleRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "branch_rule", + "type": "google.cloud.securesourcemanager_v1.types.BranchRule" + }, + { + "name": "branch_rule_id", "type": "str" }, { @@ -582,21 +550,21 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_branch_rule" + "shortName": "create_branch_rule" }, - "description": "Sample for DeleteBranchRule", - "file": "securesourcemanager_v1_generated_secure_source_manager_delete_branch_rule_async.py", + "description": "Sample for CreateBranchRule", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_branch_rule_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteBranchRule_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateBranchRule_async", "segments": [ { - "end": 55, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 56, "start": 27, "type": "SHORT" }, @@ -606,22 +574,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 53, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_delete_branch_rule_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_branch_rule_async.py" }, { "canonical": true, @@ -630,22 +598,30 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_branch_rule", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_branch_rule", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteBranchRule", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateBranchRule", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "DeleteBranchRule" + "shortName": "CreateBranchRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.DeleteBranchRuleRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreateBranchRuleRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "branch_rule", + "type": "google.cloud.securesourcemanager_v1.types.BranchRule" + }, + { + "name": "branch_rule_id", "type": "str" }, { @@ -662,21 +638,21 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "delete_branch_rule" + "shortName": "create_branch_rule" }, - "description": "Sample for DeleteBranchRule", - "file": "securesourcemanager_v1_generated_secure_source_manager_delete_branch_rule_sync.py", + "description": "Sample for CreateBranchRule", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_branch_rule_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteBranchRule_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateBranchRule_sync", "segments": [ { - "end": 55, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 56, "start": 27, "type": "SHORT" }, @@ -686,22 +662,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 53, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_delete_branch_rule_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_branch_rule_sync.py" }, { "canonical": true, @@ -711,22 +687,30 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.delete_instance", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.create_hook", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteInstance", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateHook", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "DeleteInstance" + "shortName": "CreateHook" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.DeleteInstanceRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreateHookRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "hook", + "type": "google.cloud.securesourcemanager_v1.types.Hook" + }, + { + "name": "hook_id", "type": "str" }, { @@ -743,21 +727,21 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_instance" + "shortName": "create_hook" }, - "description": "Sample for DeleteInstance", - "file": "securesourcemanager_v1_generated_secure_source_manager_delete_instance_async.py", + "description": "Sample for CreateHook", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_hook_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteInstance_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateHook_async", "segments": [ { - "end": 55, + "end": 60, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 60, "start": 27, "type": "SHORT" }, @@ -767,22 +751,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 57, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 61, + "start": 58, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_delete_instance_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_hook_async.py" }, { "canonical": true, @@ -791,22 +775,30 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_instance", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_hook", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteInstance", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateHook", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "DeleteInstance" + "shortName": "CreateHook" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.DeleteInstanceRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreateHookRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "hook", + "type": "google.cloud.securesourcemanager_v1.types.Hook" + }, + { + "name": "hook_id", "type": "str" }, { @@ -823,21 +815,21 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "delete_instance" + "shortName": "create_hook" }, - "description": "Sample for DeleteInstance", - "file": "securesourcemanager_v1_generated_secure_source_manager_delete_instance_sync.py", + "description": "Sample for CreateHook", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_hook_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteInstance_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateHook_sync", "segments": [ { - "end": 55, + "end": 60, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 60, "start": 27, "type": "SHORT" }, @@ -847,22 +839,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 57, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 61, + "start": 58, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_delete_instance_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_hook_sync.py" }, { "canonical": true, @@ -872,22 +864,30 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.delete_repository", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.create_instance", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteRepository", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateInstance", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "DeleteRepository" + "shortName": "CreateInstance" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.DeleteRepositoryRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreateInstanceRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "instance", + "type": "google.cloud.securesourcemanager_v1.types.Instance" + }, + { + "name": "instance_id", "type": "str" }, { @@ -904,21 +904,21 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_repository" + "shortName": "create_instance" }, - "description": "Sample for DeleteRepository", - "file": "securesourcemanager_v1_generated_secure_source_manager_delete_repository_async.py", + "description": "Sample for CreateInstance", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_instance_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteRepository_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateInstance_async", "segments": [ { - "end": 55, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 56, "start": 27, "type": "SHORT" }, @@ -928,22 +928,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 53, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_delete_repository_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_instance_async.py" }, { "canonical": true, @@ -952,22 +952,30 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_repository", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_instance", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteRepository", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateInstance", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "DeleteRepository" + "shortName": "CreateInstance" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.DeleteRepositoryRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreateInstanceRequest" }, { - "name": "name", + "name": "parent", + "type": "str" + }, + { + "name": "instance", + "type": "google.cloud.securesourcemanager_v1.types.Instance" + }, + { + "name": "instance_id", "type": "str" }, { @@ -984,21 +992,21 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "delete_repository" + "shortName": "create_instance" }, - "description": "Sample for DeleteRepository", - "file": "securesourcemanager_v1_generated_secure_source_manager_delete_repository_sync.py", + "description": "Sample for CreateInstance", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_instance_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteRepository_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateInstance_sync", "segments": [ { - "end": 55, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 55, + "end": 56, "start": 27, "type": "SHORT" }, @@ -1008,22 +1016,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 52, - "start": 46, + "end": 53, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 56, - "start": 53, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_delete_repository_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_instance_sync.py" }, { "canonical": true, @@ -1033,24 +1041,28 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_branch_rule", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.create_issue_comment", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetBranchRule", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateIssueComment", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "GetBranchRule" + "shortName": "CreateIssueComment" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.GetBranchRuleRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreateIssueCommentRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "issue_comment", + "type": "google.cloud.securesourcemanager_v1.types.IssueComment" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1064,22 +1076,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.securesourcemanager_v1.types.BranchRule", - "shortName": "get_branch_rule" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_issue_comment" }, - "description": "Sample for GetBranchRule", - "file": "securesourcemanager_v1_generated_secure_source_manager_get_branch_rule_async.py", + "description": "Sample for CreateIssueComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_issue_comment_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetBranchRule_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateIssueComment_async", "segments": [ { - "end": 51, + "end": 59, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 59, "start": 27, "type": "SHORT" }, @@ -1089,22 +1101,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 56, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 60, + "start": 57, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_get_branch_rule_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_issue_comment_async.py" }, { "canonical": true, @@ -1113,24 +1125,28 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_branch_rule", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_issue_comment", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetBranchRule", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateIssueComment", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "GetBranchRule" + "shortName": "CreateIssueComment" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.GetBranchRuleRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreateIssueCommentRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "issue_comment", + "type": "google.cloud.securesourcemanager_v1.types.IssueComment" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1144,22 +1160,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.securesourcemanager_v1.types.BranchRule", - "shortName": "get_branch_rule" + "resultType": "google.api_core.operation.Operation", + "shortName": "create_issue_comment" }, - "description": "Sample for GetBranchRule", - "file": "securesourcemanager_v1_generated_secure_source_manager_get_branch_rule_sync.py", + "description": "Sample for CreateIssueComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_issue_comment_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetBranchRule_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateIssueComment_sync", "segments": [ { - "end": 51, + "end": 59, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 59, "start": 27, "type": "SHORT" }, @@ -1169,22 +1185,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 56, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 60, + "start": 57, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_get_branch_rule_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_issue_comment_sync.py" }, { "canonical": true, @@ -1194,24 +1210,28 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_iam_policy_repo", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.create_issue", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetIamPolicyRepo", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateIssue", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "GetIamPolicyRepo" + "shortName": "CreateIssue" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreateIssueRequest" }, { - "name": "resource", + "name": "parent", "type": "str" }, + { + "name": "issue", + "type": "google.cloud.securesourcemanager_v1.types.Issue" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1225,47 +1245,47 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "get_iam_policy_repo" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_issue" }, - "description": "Sample for GetIamPolicyRepo", - "file": "securesourcemanager_v1_generated_secure_source_manager_get_iam_policy_repo_async.py", + "description": "Sample for CreateIssue", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_issue_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetIamPolicyRepo_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateIssue_async", "segments": [ { - "end": 52, + "end": 59, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 59, "start": 27, "type": "SHORT" }, { - "end": 41, - "start": 39, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 46, - "start": 42, + "end": 49, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 56, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 60, + "start": 57, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_get_iam_policy_repo_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_issue_async.py" }, { "canonical": true, @@ -1274,24 +1294,28 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_iam_policy_repo", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_issue", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetIamPolicyRepo", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateIssue", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "GetIamPolicyRepo" + "shortName": "CreateIssue" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreateIssueRequest" }, { - "name": "resource", + "name": "parent", "type": "str" }, + { + "name": "issue", + "type": "google.cloud.securesourcemanager_v1.types.Issue" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1305,47 +1329,47 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "get_iam_policy_repo" + "resultType": "google.api_core.operation.Operation", + "shortName": "create_issue" }, - "description": "Sample for GetIamPolicyRepo", - "file": "securesourcemanager_v1_generated_secure_source_manager_get_iam_policy_repo_sync.py", + "description": "Sample for CreateIssue", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_issue_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetIamPolicyRepo_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateIssue_sync", "segments": [ { - "end": 52, + "end": 59, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 59, "start": 27, "type": "SHORT" }, { - "end": 41, - "start": 39, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 46, - "start": 42, + "end": 49, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 56, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 60, + "start": 57, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_get_iam_policy_repo_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_issue_sync.py" }, { "canonical": true, @@ -1355,24 +1379,28 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_instance", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.create_pull_request_comment", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetInstance", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreatePullRequestComment", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "GetInstance" + "shortName": "CreatePullRequestComment" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.GetInstanceRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreatePullRequestCommentRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "pull_request_comment", + "type": "google.cloud.securesourcemanager_v1.types.PullRequestComment" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1386,22 +1414,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.securesourcemanager_v1.types.Instance", - "shortName": "get_instance" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_pull_request_comment" }, - "description": "Sample for GetInstance", - "file": "securesourcemanager_v1_generated_secure_source_manager_get_instance_async.py", + "description": "Sample for CreatePullRequestComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_pull_request_comment_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetInstance_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreatePullRequestComment_async", "segments": [ { - "end": 51, + "end": 59, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 59, "start": 27, "type": "SHORT" }, @@ -1411,22 +1439,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 56, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 60, + "start": 57, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_get_instance_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_pull_request_comment_async.py" }, { "canonical": true, @@ -1435,24 +1463,28 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_instance", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_pull_request_comment", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetInstance", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreatePullRequestComment", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "GetInstance" + "shortName": "CreatePullRequestComment" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.GetInstanceRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreatePullRequestCommentRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "pull_request_comment", + "type": "google.cloud.securesourcemanager_v1.types.PullRequestComment" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1466,22 +1498,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.securesourcemanager_v1.types.Instance", - "shortName": "get_instance" + "resultType": "google.api_core.operation.Operation", + "shortName": "create_pull_request_comment" }, - "description": "Sample for GetInstance", - "file": "securesourcemanager_v1_generated_secure_source_manager_get_instance_sync.py", + "description": "Sample for CreatePullRequestComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_pull_request_comment_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetInstance_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreatePullRequestComment_sync", "segments": [ { - "end": 51, + "end": 59, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 59, "start": 27, "type": "SHORT" }, @@ -1491,22 +1523,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 49, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 56, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 60, + "start": 57, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_get_instance_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_pull_request_comment_sync.py" }, { "canonical": true, @@ -1516,24 +1548,28 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_repository", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.create_pull_request", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetRepository", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreatePullRequest", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "GetRepository" + "shortName": "CreatePullRequest" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.GetRepositoryRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreatePullRequestRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "pull_request", + "type": "google.cloud.securesourcemanager_v1.types.PullRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1547,22 +1583,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.securesourcemanager_v1.types.Repository", - "shortName": "get_repository" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_pull_request" }, - "description": "Sample for GetRepository", - "file": "securesourcemanager_v1_generated_secure_source_manager_get_repository_async.py", + "description": "Sample for CreatePullRequest", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_pull_request_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetRepository_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreatePullRequest_async", "segments": [ { - "end": 51, + "end": 60, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 60, "start": 27, "type": "SHORT" }, @@ -1572,22 +1608,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 57, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 61, + "start": 58, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_get_repository_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_pull_request_async.py" }, { "canonical": true, @@ -1596,24 +1632,28 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_repository", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_pull_request", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetRepository", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreatePullRequest", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "GetRepository" + "shortName": "CreatePullRequest" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.GetRepositoryRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreatePullRequestRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, + { + "name": "pull_request", + "type": "google.cloud.securesourcemanager_v1.types.PullRequest" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1627,22 +1667,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.securesourcemanager_v1.types.Repository", - "shortName": "get_repository" + "resultType": "google.api_core.operation.Operation", + "shortName": "create_pull_request" }, - "description": "Sample for GetRepository", - "file": "securesourcemanager_v1_generated_secure_source_manager_get_repository_sync.py", + "description": "Sample for CreatePullRequest", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_pull_request_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetRepository_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreatePullRequest_sync", "segments": [ { - "end": 51, + "end": 60, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 60, "start": 27, "type": "SHORT" }, @@ -1652,22 +1692,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 50, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 57, + "start": 51, "type": "REQUEST_EXECUTION" }, { - "end": 52, - "start": 49, + "end": 61, + "start": 58, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_get_repository_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_pull_request_sync.py" }, { "canonical": true, @@ -1677,24 +1717,32 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.list_branch_rules", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.create_repository", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListBranchRules", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateRepository", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "ListBranchRules" + "shortName": "CreateRepository" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.ListBranchRulesRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreateRepositoryRequest" }, { "name": "parent", "type": "str" }, + { + "name": "repository", + "type": "google.cloud.securesourcemanager_v1.types.Repository" + }, + { + "name": "repository_id", + "type": "str" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1708,22 +1756,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListBranchRulesAsyncPager", - "shortName": "list_branch_rules" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_repository" }, - "description": "Sample for ListBranchRules", - "file": "securesourcemanager_v1_generated_secure_source_manager_list_branch_rules_async.py", + "description": "Sample for CreateRepository", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_repository_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListBranchRules_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateRepository_async", "segments": [ { - "end": 52, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 56, "start": 27, "type": "SHORT" }, @@ -1733,22 +1781,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 53, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_list_branch_rules_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_repository_async.py" }, { "canonical": true, @@ -1757,24 +1805,32 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_branch_rules", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.create_repository", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListBranchRules", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.CreateRepository", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "ListBranchRules" + "shortName": "CreateRepository" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.ListBranchRulesRequest" + "type": "google.cloud.securesourcemanager_v1.types.CreateRepositoryRequest" }, { "name": "parent", "type": "str" }, + { + "name": "repository", + "type": "google.cloud.securesourcemanager_v1.types.Repository" + }, + { + "name": "repository_id", + "type": "str" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -1788,22 +1844,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListBranchRulesPager", - "shortName": "list_branch_rules" + "resultType": "google.api_core.operation.Operation", + "shortName": "create_repository" }, - "description": "Sample for ListBranchRules", - "file": "securesourcemanager_v1_generated_secure_source_manager_list_branch_rules_sync.py", + "description": "Sample for CreateRepository", + "file": "securesourcemanager_v1_generated_secure_source_manager_create_repository_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListBranchRules_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_CreateRepository_sync", "segments": [ { - "end": 52, + "end": 56, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 56, "start": 27, "type": "SHORT" }, @@ -1813,22 +1869,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 46, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 53, + "start": 47, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 57, + "start": 54, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_list_branch_rules_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_create_repository_sync.py" }, { "canonical": true, @@ -1838,22 +1894,22 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.list_instances", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.delete_branch_rule", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListInstances", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteBranchRule", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "ListInstances" + "shortName": "DeleteBranchRule" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.ListInstancesRequest" + "type": "google.cloud.securesourcemanager_v1.types.DeleteBranchRuleRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, { @@ -1869,22 +1925,5838 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListInstancesAsyncPager", - "shortName": "list_instances" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_branch_rule" + }, + "description": "Sample for DeleteBranchRule", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_branch_rule_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteBranchRule_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_branch_rule_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_branch_rule", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteBranchRule", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeleteBranchRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeleteBranchRuleRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_branch_rule" + }, + "description": "Sample for DeleteBranchRule", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_branch_rule_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteBranchRule_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_branch_rule_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.delete_hook", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteHook", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeleteHook" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeleteHookRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_hook" + }, + "description": "Sample for DeleteHook", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_hook_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteHook_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_hook_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_hook", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteHook", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeleteHook" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeleteHookRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_hook" + }, + "description": "Sample for DeleteHook", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_hook_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteHook_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_hook_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.delete_instance", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteInstance", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeleteInstance" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeleteInstanceRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_instance" + }, + "description": "Sample for DeleteInstance", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_instance_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteInstance_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_instance_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_instance", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteInstance", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeleteInstance" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeleteInstanceRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_instance" + }, + "description": "Sample for DeleteInstance", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_instance_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteInstance_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_instance_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.delete_issue_comment", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteIssueComment", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeleteIssueComment" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeleteIssueCommentRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_issue_comment" + }, + "description": "Sample for DeleteIssueComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_issue_comment_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteIssueComment_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_issue_comment_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_issue_comment", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteIssueComment", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeleteIssueComment" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeleteIssueCommentRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_issue_comment" + }, + "description": "Sample for DeleteIssueComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_issue_comment_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteIssueComment_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_issue_comment_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.delete_issue", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteIssue", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeleteIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeleteIssueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_issue" + }, + "description": "Sample for DeleteIssue", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_issue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteIssue_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_issue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_issue", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteIssue", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeleteIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeleteIssueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_issue" + }, + "description": "Sample for DeleteIssue", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_issue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteIssue_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_issue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.delete_pull_request_comment", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeletePullRequestComment", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeletePullRequestComment" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeletePullRequestCommentRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_pull_request_comment" + }, + "description": "Sample for DeletePullRequestComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_pull_request_comment_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeletePullRequestComment_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_pull_request_comment_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_pull_request_comment", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeletePullRequestComment", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeletePullRequestComment" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeletePullRequestCommentRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_pull_request_comment" + }, + "description": "Sample for DeletePullRequestComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_pull_request_comment_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeletePullRequestComment_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_pull_request_comment_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.delete_repository", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteRepository", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeleteRepository" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeleteRepositoryRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_repository" + }, + "description": "Sample for DeleteRepository", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_repository_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteRepository_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_repository_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.delete_repository", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.DeleteRepository", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "DeleteRepository" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.DeleteRepositoryRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_repository" + }, + "description": "Sample for DeleteRepository", + "file": "securesourcemanager_v1_generated_secure_source_manager_delete_repository_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_DeleteRepository_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_delete_repository_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.fetch_blob", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.FetchBlob", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "FetchBlob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.FetchBlobRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.FetchBlobResponse", + "shortName": "fetch_blob" + }, + "description": "Sample for FetchBlob", + "file": "securesourcemanager_v1_generated_secure_source_manager_fetch_blob_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_FetchBlob_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_fetch_blob_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.fetch_blob", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.FetchBlob", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "FetchBlob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.FetchBlobRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.FetchBlobResponse", + "shortName": "fetch_blob" + }, + "description": "Sample for FetchBlob", + "file": "securesourcemanager_v1_generated_secure_source_manager_fetch_blob_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_FetchBlob_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_fetch_blob_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.fetch_tree", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.FetchTree", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "FetchTree" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.FetchTreeRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.FetchTreeAsyncPager", + "shortName": "fetch_tree" + }, + "description": "Sample for FetchTree", + "file": "securesourcemanager_v1_generated_secure_source_manager_fetch_tree_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_FetchTree_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_fetch_tree_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.fetch_tree", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.FetchTree", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "FetchTree" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.FetchTreeRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.FetchTreePager", + "shortName": "fetch_tree" + }, + "description": "Sample for FetchTree", + "file": "securesourcemanager_v1_generated_secure_source_manager_fetch_tree_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_FetchTree_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_fetch_tree_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_branch_rule", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetBranchRule", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetBranchRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetBranchRuleRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.BranchRule", + "shortName": "get_branch_rule" + }, + "description": "Sample for GetBranchRule", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_branch_rule_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetBranchRule_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_branch_rule_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_branch_rule", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetBranchRule", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetBranchRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetBranchRuleRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.BranchRule", + "shortName": "get_branch_rule" + }, + "description": "Sample for GetBranchRule", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_branch_rule_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetBranchRule_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_branch_rule_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_hook", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetHook", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetHook" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetHookRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.Hook", + "shortName": "get_hook" + }, + "description": "Sample for GetHook", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_hook_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetHook_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_hook_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_hook", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetHook", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetHook" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetHookRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.Hook", + "shortName": "get_hook" + }, + "description": "Sample for GetHook", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_hook_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetHook_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_hook_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_iam_policy_repo", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetIamPolicyRepo", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetIamPolicyRepo" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy_repo" + }, + "description": "Sample for GetIamPolicyRepo", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_iam_policy_repo_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetIamPolicyRepo_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_iam_policy_repo_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_iam_policy_repo", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetIamPolicyRepo", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetIamPolicyRepo" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy_repo" + }, + "description": "Sample for GetIamPolicyRepo", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_iam_policy_repo_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetIamPolicyRepo_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_iam_policy_repo_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_instance", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetInstance", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetInstance" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetInstanceRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.Instance", + "shortName": "get_instance" + }, + "description": "Sample for GetInstance", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_instance_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetInstance_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_instance_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_instance", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetInstance", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetInstance" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetInstanceRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.Instance", + "shortName": "get_instance" + }, + "description": "Sample for GetInstance", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_instance_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetInstance_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_instance_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_issue_comment", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetIssueComment", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetIssueComment" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetIssueCommentRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.IssueComment", + "shortName": "get_issue_comment" + }, + "description": "Sample for GetIssueComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_issue_comment_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetIssueComment_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_issue_comment_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_issue_comment", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetIssueComment", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetIssueComment" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetIssueCommentRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.IssueComment", + "shortName": "get_issue_comment" + }, + "description": "Sample for GetIssueComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_issue_comment_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetIssueComment_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_issue_comment_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_issue", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetIssue", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetIssueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.Issue", + "shortName": "get_issue" + }, + "description": "Sample for GetIssue", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_issue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetIssue_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_issue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_issue", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetIssue", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetIssueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.Issue", + "shortName": "get_issue" + }, + "description": "Sample for GetIssue", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_issue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetIssue_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_issue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_pull_request_comment", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetPullRequestComment", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetPullRequestComment" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetPullRequestCommentRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.PullRequestComment", + "shortName": "get_pull_request_comment" + }, + "description": "Sample for GetPullRequestComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_pull_request_comment_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetPullRequestComment_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_pull_request_comment_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_pull_request_comment", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetPullRequestComment", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetPullRequestComment" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetPullRequestCommentRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.PullRequestComment", + "shortName": "get_pull_request_comment" + }, + "description": "Sample for GetPullRequestComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_pull_request_comment_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetPullRequestComment_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_pull_request_comment_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_pull_request", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetPullRequest", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetPullRequest" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetPullRequestRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.PullRequest", + "shortName": "get_pull_request" + }, + "description": "Sample for GetPullRequest", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_pull_request_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetPullRequest_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_pull_request_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_pull_request", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetPullRequest", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetPullRequest" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetPullRequestRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.PullRequest", + "shortName": "get_pull_request" + }, + "description": "Sample for GetPullRequest", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_pull_request_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetPullRequest_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_pull_request_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.get_repository", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetRepository", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetRepository" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetRepositoryRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.Repository", + "shortName": "get_repository" + }, + "description": "Sample for GetRepository", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_repository_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetRepository_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_repository_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.get_repository", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.GetRepository", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "GetRepository" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.GetRepositoryRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.types.Repository", + "shortName": "get_repository" + }, + "description": "Sample for GetRepository", + "file": "securesourcemanager_v1_generated_secure_source_manager_get_repository_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_GetRepository_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_get_repository_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.list_branch_rules", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListBranchRules", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListBranchRules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListBranchRulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListBranchRulesAsyncPager", + "shortName": "list_branch_rules" + }, + "description": "Sample for ListBranchRules", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_branch_rules_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListBranchRules_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_branch_rules_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_branch_rules", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListBranchRules", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListBranchRules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListBranchRulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListBranchRulesPager", + "shortName": "list_branch_rules" + }, + "description": "Sample for ListBranchRules", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_branch_rules_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListBranchRules_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_branch_rules_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.list_hooks", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListHooks", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListHooks" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListHooksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListHooksAsyncPager", + "shortName": "list_hooks" + }, + "description": "Sample for ListHooks", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_hooks_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListHooks_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_hooks_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_hooks", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListHooks", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListHooks" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListHooksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListHooksPager", + "shortName": "list_hooks" + }, + "description": "Sample for ListHooks", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_hooks_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListHooks_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_hooks_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.list_instances", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListInstances", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListInstances" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListInstancesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListInstancesAsyncPager", + "shortName": "list_instances" + }, + "description": "Sample for ListInstances", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_instances_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListInstances_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_instances_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_instances", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListInstances", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListInstances" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListInstancesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListInstancesPager", + "shortName": "list_instances" + }, + "description": "Sample for ListInstances", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_instances_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListInstances_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_instances_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.list_issue_comments", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListIssueComments", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListIssueComments" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListIssueCommentsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListIssueCommentsAsyncPager", + "shortName": "list_issue_comments" + }, + "description": "Sample for ListIssueComments", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_issue_comments_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListIssueComments_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_issue_comments_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_issue_comments", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListIssueComments", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListIssueComments" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListIssueCommentsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListIssueCommentsPager", + "shortName": "list_issue_comments" + }, + "description": "Sample for ListIssueComments", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_issue_comments_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListIssueComments_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_issue_comments_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.list_issues", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListIssues", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListIssues" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListIssuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListIssuesAsyncPager", + "shortName": "list_issues" + }, + "description": "Sample for ListIssues", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_issues_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListIssues_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_issues_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_issues", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListIssues", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListIssues" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListIssuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListIssuesPager", + "shortName": "list_issues" + }, + "description": "Sample for ListIssues", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_issues_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListIssues_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_issues_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.list_pull_request_comments", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListPullRequestComments", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListPullRequestComments" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListPullRequestCommentsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListPullRequestCommentsAsyncPager", + "shortName": "list_pull_request_comments" + }, + "description": "Sample for ListPullRequestComments", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_pull_request_comments_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListPullRequestComments_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_pull_request_comments_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_pull_request_comments", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListPullRequestComments", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListPullRequestComments" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListPullRequestCommentsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListPullRequestCommentsPager", + "shortName": "list_pull_request_comments" + }, + "description": "Sample for ListPullRequestComments", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_pull_request_comments_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListPullRequestComments_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_pull_request_comments_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.list_pull_request_file_diffs", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListPullRequestFileDiffs", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListPullRequestFileDiffs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListPullRequestFileDiffsRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListPullRequestFileDiffsAsyncPager", + "shortName": "list_pull_request_file_diffs" + }, + "description": "Sample for ListPullRequestFileDiffs", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_pull_request_file_diffs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListPullRequestFileDiffs_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_pull_request_file_diffs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_pull_request_file_diffs", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListPullRequestFileDiffs", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListPullRequestFileDiffs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListPullRequestFileDiffsRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListPullRequestFileDiffsPager", + "shortName": "list_pull_request_file_diffs" + }, + "description": "Sample for ListPullRequestFileDiffs", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_pull_request_file_diffs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListPullRequestFileDiffs_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_pull_request_file_diffs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.list_pull_requests", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListPullRequests", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListPullRequests" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListPullRequestsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListPullRequestsAsyncPager", + "shortName": "list_pull_requests" + }, + "description": "Sample for ListPullRequests", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_pull_requests_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListPullRequests_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_pull_requests_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_pull_requests", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListPullRequests", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListPullRequests" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListPullRequestsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListPullRequestsPager", + "shortName": "list_pull_requests" + }, + "description": "Sample for ListPullRequests", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_pull_requests_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListPullRequests_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_pull_requests_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.list_repositories", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListRepositories", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListRepositories" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListRepositoriesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListRepositoriesAsyncPager", + "shortName": "list_repositories" + }, + "description": "Sample for ListRepositories", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_repositories_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListRepositories_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_repositories_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_repositories", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListRepositories", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ListRepositories" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ListRepositoriesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListRepositoriesPager", + "shortName": "list_repositories" + }, + "description": "Sample for ListRepositories", + "file": "securesourcemanager_v1_generated_secure_source_manager_list_repositories_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListRepositories_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_list_repositories_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.merge_pull_request", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.MergePullRequest", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "MergePullRequest" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.MergePullRequestRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "merge_pull_request" + }, + "description": "Sample for MergePullRequest", + "file": "securesourcemanager_v1_generated_secure_source_manager_merge_pull_request_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_MergePullRequest_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_merge_pull_request_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.merge_pull_request", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.MergePullRequest", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "MergePullRequest" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.MergePullRequestRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "merge_pull_request" + }, + "description": "Sample for MergePullRequest", + "file": "securesourcemanager_v1_generated_secure_source_manager_merge_pull_request_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_MergePullRequest_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_merge_pull_request_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.open_issue", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.OpenIssue", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "OpenIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.OpenIssueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "open_issue" + }, + "description": "Sample for OpenIssue", + "file": "securesourcemanager_v1_generated_secure_source_manager_open_issue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_OpenIssue_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_open_issue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.open_issue", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.OpenIssue", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "OpenIssue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.OpenIssueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "open_issue" + }, + "description": "Sample for OpenIssue", + "file": "securesourcemanager_v1_generated_secure_source_manager_open_issue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_OpenIssue_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_open_issue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.open_pull_request", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.OpenPullRequest", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "OpenPullRequest" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.OpenPullRequestRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "open_pull_request" + }, + "description": "Sample for OpenPullRequest", + "file": "securesourcemanager_v1_generated_secure_source_manager_open_pull_request_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_OpenPullRequest_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_open_pull_request_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.open_pull_request", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.OpenPullRequest", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "OpenPullRequest" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.OpenPullRequestRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "open_pull_request" + }, + "description": "Sample for OpenPullRequest", + "file": "securesourcemanager_v1_generated_secure_source_manager_open_pull_request_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_OpenPullRequest_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_open_pull_request_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.resolve_pull_request_comments", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ResolvePullRequestComments", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ResolvePullRequestComments" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ResolvePullRequestCommentsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "names", + "type": "MutableSequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "resolve_pull_request_comments" + }, + "description": "Sample for ResolvePullRequestComments", + "file": "securesourcemanager_v1_generated_secure_source_manager_resolve_pull_request_comments_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ResolvePullRequestComments_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_resolve_pull_request_comments_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.resolve_pull_request_comments", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ResolvePullRequestComments", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "ResolvePullRequestComments" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.ResolvePullRequestCommentsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "names", + "type": "MutableSequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "resolve_pull_request_comments" + }, + "description": "Sample for ResolvePullRequestComments", + "file": "securesourcemanager_v1_generated_secure_source_manager_resolve_pull_request_comments_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ResolvePullRequestComments_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_resolve_pull_request_comments_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.set_iam_policy_repo", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.SetIamPolicyRepo", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "SetIamPolicyRepo" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy_repo" + }, + "description": "Sample for SetIamPolicyRepo", + "file": "securesourcemanager_v1_generated_secure_source_manager_set_iam_policy_repo_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_SetIamPolicyRepo_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_set_iam_policy_repo_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.set_iam_policy_repo", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.SetIamPolicyRepo", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "SetIamPolicyRepo" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy_repo" + }, + "description": "Sample for SetIamPolicyRepo", + "file": "securesourcemanager_v1_generated_secure_source_manager_set_iam_policy_repo_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_SetIamPolicyRepo_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_set_iam_policy_repo_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.test_iam_permissions_repo", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.TestIamPermissionsRepo", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "TestIamPermissionsRepo" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions_repo" + }, + "description": "Sample for TestIamPermissionsRepo", + "file": "securesourcemanager_v1_generated_secure_source_manager_test_iam_permissions_repo_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_TestIamPermissionsRepo_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_test_iam_permissions_repo_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.test_iam_permissions_repo", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.TestIamPermissionsRepo", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "TestIamPermissionsRepo" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions_repo" + }, + "description": "Sample for TestIamPermissionsRepo", + "file": "securesourcemanager_v1_generated_secure_source_manager_test_iam_permissions_repo_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_TestIamPermissionsRepo_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_test_iam_permissions_repo_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.unresolve_pull_request_comments", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UnresolvePullRequestComments", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "UnresolvePullRequestComments" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.UnresolvePullRequestCommentsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "names", + "type": "MutableSequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "unresolve_pull_request_comments" + }, + "description": "Sample for UnresolvePullRequestComments", + "file": "securesourcemanager_v1_generated_secure_source_manager_unresolve_pull_request_comments_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UnresolvePullRequestComments_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_unresolve_pull_request_comments_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.unresolve_pull_request_comments", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UnresolvePullRequestComments", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "UnresolvePullRequestComments" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.UnresolvePullRequestCommentsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "names", + "type": "MutableSequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "unresolve_pull_request_comments" + }, + "description": "Sample for UnresolvePullRequestComments", + "file": "securesourcemanager_v1_generated_secure_source_manager_unresolve_pull_request_comments_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UnresolvePullRequestComments_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_unresolve_pull_request_comments_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.update_branch_rule", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdateBranchRule", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "UpdateBranchRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.UpdateBranchRuleRequest" + }, + { + "name": "branch_rule", + "type": "google.cloud.securesourcemanager_v1.types.BranchRule" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_branch_rule" + }, + "description": "Sample for UpdateBranchRule", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_branch_rule_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdateBranchRule_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_update_branch_rule_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_branch_rule", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdateBranchRule", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "UpdateBranchRule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.UpdateBranchRuleRequest" + }, + { + "name": "branch_rule", + "type": "google.cloud.securesourcemanager_v1.types.BranchRule" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_branch_rule" + }, + "description": "Sample for UpdateBranchRule", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_branch_rule_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdateBranchRule_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_update_branch_rule_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.update_hook", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdateHook", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "UpdateHook" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.UpdateHookRequest" + }, + { + "name": "hook", + "type": "google.cloud.securesourcemanager_v1.types.Hook" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_hook" + }, + "description": "Sample for UpdateHook", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_hook_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdateHook_async", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_update_hook_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", + "shortName": "SecureSourceManagerClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_hook", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdateHook", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "UpdateHook" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.UpdateHookRequest" + }, + { + "name": "hook", + "type": "google.cloud.securesourcemanager_v1.types.Hook" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_hook" + }, + "description": "Sample for UpdateHook", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_hook_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdateHook_sync", + "segments": [ + { + "end": 58, + "start": 27, + "type": "FULL" + }, + { + "end": 58, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 48, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 49, + "type": "REQUEST_EXECUTION" + }, + { + "end": 59, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securesourcemanager_v1_generated_secure_source_manager_update_hook_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", + "shortName": "SecureSourceManagerAsyncClient" + }, + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.update_issue_comment", + "method": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdateIssueComment", + "service": { + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", + "shortName": "SecureSourceManager" + }, + "shortName": "UpdateIssueComment" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securesourcemanager_v1.types.UpdateIssueCommentRequest" + }, + { + "name": "issue_comment", + "type": "google.cloud.securesourcemanager_v1.types.IssueComment" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_issue_comment" }, - "description": "Sample for ListInstances", - "file": "securesourcemanager_v1_generated_secure_source_manager_list_instances_async.py", + "description": "Sample for UpdateIssueComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_issue_comment_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListInstances_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdateIssueComment_async", "segments": [ { - "end": 52, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 58, "start": 27, "type": "SHORT" }, @@ -1894,22 +7766,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 55, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_list_instances_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_update_issue_comment_async.py" }, { "canonical": true, @@ -1918,23 +7790,27 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_instances", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_issue_comment", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListInstances", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdateIssueComment", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "ListInstances" + "shortName": "UpdateIssueComment" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.ListInstancesRequest" + "type": "google.cloud.securesourcemanager_v1.types.UpdateIssueCommentRequest" }, { - "name": "parent", - "type": "str" + "name": "issue_comment", + "type": "google.cloud.securesourcemanager_v1.types.IssueComment" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -1949,22 +7825,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListInstancesPager", - "shortName": "list_instances" + "resultType": "google.api_core.operation.Operation", + "shortName": "update_issue_comment" }, - "description": "Sample for ListInstances", - "file": "securesourcemanager_v1_generated_secure_source_manager_list_instances_sync.py", + "description": "Sample for UpdateIssueComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_issue_comment_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListInstances_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdateIssueComment_sync", "segments": [ { - "end": 52, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 58, "start": 27, "type": "SHORT" }, @@ -1974,22 +7850,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 55, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_list_instances_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_update_issue_comment_sync.py" }, { "canonical": true, @@ -1999,23 +7875,27 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.list_repositories", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.update_issue", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListRepositories", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdateIssue", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "ListRepositories" + "shortName": "UpdateIssue" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.ListRepositoriesRequest" + "type": "google.cloud.securesourcemanager_v1.types.UpdateIssueRequest" }, { - "name": "parent", - "type": "str" + "name": "issue", + "type": "google.cloud.securesourcemanager_v1.types.Issue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -2030,22 +7910,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListRepositoriesAsyncPager", - "shortName": "list_repositories" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_issue" }, - "description": "Sample for ListRepositories", - "file": "securesourcemanager_v1_generated_secure_source_manager_list_repositories_async.py", + "description": "Sample for UpdateIssue", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_issue_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListRepositories_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdateIssue_async", "segments": [ { - "end": 52, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 58, "start": 27, "type": "SHORT" }, @@ -2055,22 +7935,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 55, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_list_repositories_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_update_issue_async.py" }, { "canonical": true, @@ -2079,23 +7959,27 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.list_repositories", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_issue", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.ListRepositories", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdateIssue", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "ListRepositories" + "shortName": "UpdateIssue" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.ListRepositoriesRequest" + "type": "google.cloud.securesourcemanager_v1.types.UpdateIssueRequest" }, { - "name": "parent", - "type": "str" + "name": "issue", + "type": "google.cloud.securesourcemanager_v1.types.Issue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -2110,22 +7994,22 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.cloud.securesourcemanager_v1.services.secure_source_manager.pagers.ListRepositoriesPager", - "shortName": "list_repositories" + "resultType": "google.api_core.operation.Operation", + "shortName": "update_issue" }, - "description": "Sample for ListRepositories", - "file": "securesourcemanager_v1_generated_secure_source_manager_list_repositories_sync.py", + "description": "Sample for UpdateIssue", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_issue_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_ListRepositories_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdateIssue_sync", "segments": [ { - "end": 52, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 58, "start": 27, "type": "SHORT" }, @@ -2135,22 +8019,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 48, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 55, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_list_repositories_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_update_issue_sync.py" }, { "canonical": true, @@ -2160,23 +8044,27 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.set_iam_policy_repo", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.update_pull_request_comment", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.SetIamPolicyRepo", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdatePullRequestComment", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "SetIamPolicyRepo" + "shortName": "UpdatePullRequestComment" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + "type": "google.cloud.securesourcemanager_v1.types.UpdatePullRequestCommentRequest" }, { - "name": "resource", - "type": "str" + "name": "pull_request_comment", + "type": "google.cloud.securesourcemanager_v1.types.PullRequestComment" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -2191,47 +8079,47 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "set_iam_policy_repo" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_pull_request_comment" }, - "description": "Sample for SetIamPolicyRepo", - "file": "securesourcemanager_v1_generated_secure_source_manager_set_iam_policy_repo_async.py", + "description": "Sample for UpdatePullRequestComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_pull_request_comment_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_SetIamPolicyRepo_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdatePullRequestComment_async", "segments": [ { - "end": 52, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 58, "start": 27, "type": "SHORT" }, { - "end": 41, - "start": 39, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 46, - "start": 42, + "end": 48, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 55, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_set_iam_policy_repo_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_update_pull_request_comment_async.py" }, { "canonical": true, @@ -2240,23 +8128,27 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.set_iam_policy_repo", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_pull_request_comment", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.SetIamPolicyRepo", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdatePullRequestComment", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "SetIamPolicyRepo" + "shortName": "UpdatePullRequestComment" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + "type": "google.cloud.securesourcemanager_v1.types.UpdatePullRequestCommentRequest" }, { - "name": "resource", - "type": "str" + "name": "pull_request_comment", + "type": "google.cloud.securesourcemanager_v1.types.PullRequestComment" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -2271,47 +8163,47 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.iam.v1.policy_pb2.Policy", - "shortName": "set_iam_policy_repo" + "resultType": "google.api_core.operation.Operation", + "shortName": "update_pull_request_comment" }, - "description": "Sample for SetIamPolicyRepo", - "file": "securesourcemanager_v1_generated_secure_source_manager_set_iam_policy_repo_sync.py", + "description": "Sample for UpdatePullRequestComment", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_pull_request_comment_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_SetIamPolicyRepo_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdatePullRequestComment_sync", "segments": [ { - "end": 52, + "end": 58, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 58, "start": 27, "type": "SHORT" }, { - "end": 41, - "start": 39, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 46, - "start": 42, + "end": 48, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 49, - "start": 47, + "end": 55, + "start": 49, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 50, + "end": 59, + "start": 56, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_set_iam_policy_repo_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_update_pull_request_comment_sync.py" }, { "canonical": true, @@ -2321,23 +8213,27 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.test_iam_permissions_repo", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.update_pull_request", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.TestIamPermissionsRepo", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdatePullRequest", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "TestIamPermissionsRepo" + "shortName": "UpdatePullRequest" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + "type": "google.cloud.securesourcemanager_v1.types.UpdatePullRequestRequest" }, { - "name": "resource", - "type": "str" + "name": "pull_request", + "type": "google.cloud.securesourcemanager_v1.types.PullRequest" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -2352,47 +8248,47 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", - "shortName": "test_iam_permissions_repo" + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_pull_request" }, - "description": "Sample for TestIamPermissionsRepo", - "file": "securesourcemanager_v1_generated_secure_source_manager_test_iam_permissions_repo_async.py", + "description": "Sample for UpdatePullRequest", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_pull_request_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_TestIamPermissionsRepo_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdatePullRequest_async", "segments": [ { - "end": 53, + "end": 59, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 59, "start": 27, "type": "SHORT" }, { - "end": 41, - "start": 39, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 47, - "start": 42, + "end": 49, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 56, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 60, + "start": 57, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_test_iam_permissions_repo_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_update_pull_request_async.py" }, { "canonical": true, @@ -2401,23 +8297,27 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.test_iam_permissions_repo", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_pull_request", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.TestIamPermissionsRepo", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdatePullRequest", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "TestIamPermissionsRepo" + "shortName": "UpdatePullRequest" }, "parameters": [ { "name": "request", - "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + "type": "google.cloud.securesourcemanager_v1.types.UpdatePullRequestRequest" }, { - "name": "resource", - "type": "str" + "name": "pull_request", + "type": "google.cloud.securesourcemanager_v1.types.PullRequest" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -2432,47 +8332,47 @@ "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], - "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", - "shortName": "test_iam_permissions_repo" + "resultType": "google.api_core.operation.Operation", + "shortName": "update_pull_request" }, - "description": "Sample for TestIamPermissionsRepo", - "file": "securesourcemanager_v1_generated_secure_source_manager_test_iam_permissions_repo_sync.py", + "description": "Sample for UpdatePullRequest", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_pull_request_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_TestIamPermissionsRepo_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdatePullRequest_sync", "segments": [ { - "end": 53, + "end": 59, "start": 27, "type": "FULL" }, { - "end": 53, + "end": 59, "start": 27, "type": "SHORT" }, { - "end": 41, - "start": 39, + "end": 40, + "start": 38, "type": "CLIENT_INITIALIZATION" }, { - "end": 47, - "start": 42, + "end": 49, + "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 50, - "start": 48, + "end": 56, + "start": 50, "type": "REQUEST_EXECUTION" }, { - "end": 54, - "start": 51, + "end": 60, + "start": 57, "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_test_iam_permissions_repo_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_update_pull_request_sync.py" }, { "canonical": true, @@ -2482,23 +8382,23 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient", "shortName": "SecureSourceManagerAsyncClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.update_branch_rule", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerAsyncClient.update_repository", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdateBranchRule", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdateRepository", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "UpdateBranchRule" + "shortName": "UpdateRepository" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.UpdateBranchRuleRequest" + "type": "google.cloud.securesourcemanager_v1.types.UpdateRepositoryRequest" }, { - "name": "branch_rule", - "type": "google.cloud.securesourcemanager_v1.types.BranchRule" + "name": "repository", + "type": "google.cloud.securesourcemanager_v1.types.Repository" }, { "name": "update_mask", @@ -2518,13 +8418,13 @@ } ], "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_branch_rule" + "shortName": "update_repository" }, - "description": "Sample for UpdateBranchRule", - "file": "securesourcemanager_v1_generated_secure_source_manager_update_branch_rule_async.py", + "description": "Sample for UpdateRepository", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_repository_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdateBranchRule_async", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdateRepository_async", "segments": [ { "end": 54, @@ -2557,7 +8457,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_update_branch_rule_async.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_update_repository_async.py" }, { "canonical": true, @@ -2566,23 +8466,23 @@ "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient", "shortName": "SecureSourceManagerClient" }, - "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_branch_rule", + "fullName": "google.cloud.securesourcemanager_v1.SecureSourceManagerClient.update_repository", "method": { - "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdateBranchRule", + "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager.UpdateRepository", "service": { "fullName": "google.cloud.securesourcemanager.v1.SecureSourceManager", "shortName": "SecureSourceManager" }, - "shortName": "UpdateBranchRule" + "shortName": "UpdateRepository" }, "parameters": [ { "name": "request", - "type": "google.cloud.securesourcemanager_v1.types.UpdateBranchRuleRequest" + "type": "google.cloud.securesourcemanager_v1.types.UpdateRepositoryRequest" }, { - "name": "branch_rule", - "type": "google.cloud.securesourcemanager_v1.types.BranchRule" + "name": "repository", + "type": "google.cloud.securesourcemanager_v1.types.Repository" }, { "name": "update_mask", @@ -2602,13 +8502,13 @@ } ], "resultType": "google.api_core.operation.Operation", - "shortName": "update_branch_rule" + "shortName": "update_repository" }, - "description": "Sample for UpdateBranchRule", - "file": "securesourcemanager_v1_generated_secure_source_manager_update_branch_rule_sync.py", + "description": "Sample for UpdateRepository", + "file": "securesourcemanager_v1_generated_secure_source_manager_update_repository_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdateBranchRule_sync", + "regionTag": "securesourcemanager_v1_generated_SecureSourceManager_UpdateRepository_sync", "segments": [ { "end": 54, @@ -2641,7 +8541,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "securesourcemanager_v1_generated_secure_source_manager_update_branch_rule_sync.py" + "title": "securesourcemanager_v1_generated_secure_source_manager_update_repository_sync.py" } ] } diff --git a/packages/google-cloud-securesourcemanager/scripts/fixup_securesourcemanager_v1_keywords.py b/packages/google-cloud-securesourcemanager/scripts/fixup_securesourcemanager_v1_keywords.py index fcba2e8d6d47..2462756faac9 100644 --- a/packages/google-cloud-securesourcemanager/scripts/fixup_securesourcemanager_v1_keywords.py +++ b/packages/google-cloud-securesourcemanager/scripts/fixup_securesourcemanager_v1_keywords.py @@ -39,22 +39,58 @@ def partition( class securesourcemanagerCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'batch_create_pull_request_comments': ('parent', 'requests', ), + 'close_issue': ('name', 'etag', ), + 'close_pull_request': ('name', ), 'create_branch_rule': ('parent', 'branch_rule', 'branch_rule_id', ), + 'create_hook': ('parent', 'hook', 'hook_id', ), 'create_instance': ('parent', 'instance_id', 'instance', 'request_id', ), + 'create_issue': ('parent', 'issue', ), + 'create_issue_comment': ('parent', 'issue_comment', ), + 'create_pull_request': ('parent', 'pull_request', ), + 'create_pull_request_comment': ('parent', 'pull_request_comment', ), 'create_repository': ('parent', 'repository', 'repository_id', ), 'delete_branch_rule': ('name', 'allow_missing', ), + 'delete_hook': ('name', ), 'delete_instance': ('name', 'request_id', ), + 'delete_issue': ('name', 'etag', ), + 'delete_issue_comment': ('name', ), + 'delete_pull_request_comment': ('name', ), 'delete_repository': ('name', 'allow_missing', ), + 'fetch_blob': ('repository', 'sha', ), + 'fetch_tree': ('repository', 'ref', 'recursive', 'page_size', 'page_token', ), 'get_branch_rule': ('name', ), + 'get_hook': ('name', ), 'get_iam_policy_repo': ('resource', 'options', ), 'get_instance': ('name', ), + 'get_issue': ('name', ), + 'get_issue_comment': ('name', ), + 'get_pull_request': ('name', ), + 'get_pull_request_comment': ('name', ), 'get_repository': ('name', ), 'list_branch_rules': ('parent', 'page_size', 'page_token', ), + 'list_hooks': ('parent', 'page_size', 'page_token', ), 'list_instances': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_issue_comments': ('parent', 'page_size', 'page_token', ), + 'list_issues': ('parent', 'page_size', 'page_token', 'filter', ), + 'list_pull_request_comments': ('parent', 'page_size', 'page_token', ), + 'list_pull_request_file_diffs': ('name', 'page_size', 'page_token', ), + 'list_pull_requests': ('parent', 'page_size', 'page_token', ), 'list_repositories': ('parent', 'page_size', 'page_token', 'filter', 'instance', ), + 'merge_pull_request': ('name', ), + 'open_issue': ('name', 'etag', ), + 'open_pull_request': ('name', ), + 'resolve_pull_request_comments': ('parent', 'names', 'auto_fill', ), 'set_iam_policy_repo': ('resource', 'policy', 'update_mask', ), 'test_iam_permissions_repo': ('resource', 'permissions', ), + 'unresolve_pull_request_comments': ('parent', 'names', 'auto_fill', ), 'update_branch_rule': ('branch_rule', 'update_mask', 'validate_only', ), + 'update_hook': ('update_mask', 'hook', ), + 'update_issue': ('issue', 'update_mask', ), + 'update_issue_comment': ('issue_comment', 'update_mask', ), + 'update_pull_request': ('pull_request', 'update_mask', ), + 'update_pull_request_comment': ('pull_request_comment', 'update_mask', ), + 'update_repository': ('repository', 'update_mask', 'validate_only', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: diff --git a/packages/google-cloud-securesourcemanager/tests/unit/gapic/securesourcemanager_v1/test_secure_source_manager.py b/packages/google-cloud-securesourcemanager/tests/unit/gapic/securesourcemanager_v1/test_secure_source_manager.py index 8d6650e657a8..531202d27ba0 100644 --- a/packages/google-cloud-securesourcemanager/tests/unit/gapic/securesourcemanager_v1/test_secure_source_manager.py +++ b/packages/google-cloud-securesourcemanager/tests/unit/gapic/securesourcemanager_v1/test_secure_source_manager.py @@ -3997,11 +3997,11 @@ async def test_create_repository_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - secure_source_manager.DeleteRepositoryRequest, + secure_source_manager.UpdateRepositoryRequest, dict, ], ) -def test_delete_repository(request_type, transport: str = "grpc"): +def test_update_repository(request_type, transport: str = "grpc"): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -4013,23 +4013,23 @@ def test_delete_repository(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.update_repository), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_repository(request) + response = client.update_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = secure_source_manager.DeleteRepositoryRequest() + request = secure_source_manager.UpdateRepositoryRequest() assert args[0] == request # Establish that the response is the type that we expect. assert isinstance(response, future.Future) -def test_delete_repository_non_empty_request_with_auto_populated_field(): +def test_update_repository_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = SecureSourceManagerClient( @@ -4040,26 +4040,22 @@ def test_delete_repository_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = secure_source_manager.DeleteRepositoryRequest( - name="name_value", - ) + request = secure_source_manager.UpdateRepositoryRequest() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.update_repository), "__call__" ) as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.delete_repository(request=request) + client.update_repository(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == secure_source_manager.DeleteRepositoryRequest( - name="name_value", - ) + assert args[0] == secure_source_manager.UpdateRepositoryRequest() -def test_delete_repository_use_cached_wrapped_rpc(): +def test_update_repository_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -4073,7 +4069,7 @@ def test_delete_repository_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_repository in client._transport._wrapped_methods + assert client._transport.update_repository in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -4081,10 +4077,10 @@ def test_delete_repository_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.delete_repository + client._transport.update_repository ] = mock_rpc request = {} - client.delete_repository(request) + client.update_repository(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -4094,7 +4090,7 @@ def test_delete_repository_use_cached_wrapped_rpc(): # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.delete_repository(request) + client.update_repository(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -4102,7 +4098,7 @@ def test_delete_repository_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_delete_repository_async_use_cached_wrapped_rpc( +async def test_update_repository_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -4119,7 +4115,7 @@ async def test_delete_repository_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.delete_repository + client._client._transport.update_repository in client._client._transport._wrapped_methods ) @@ -4127,11 +4123,11 @@ async def test_delete_repository_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.delete_repository + client._client._transport.update_repository ] = mock_rpc request = {} - await client.delete_repository(request) + await client.update_repository(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -4141,7 +4137,7 @@ async def test_delete_repository_async_use_cached_wrapped_rpc( # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - await client.delete_repository(request) + await client.update_repository(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -4149,9 +4145,9 @@ async def test_delete_repository_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_delete_repository_async( +async def test_update_repository_async( transport: str = "grpc_asyncio", - request_type=secure_source_manager.DeleteRepositoryRequest, + request_type=secure_source_manager.UpdateRepositoryRequest, ): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), @@ -4164,18 +4160,18 @@ async def test_delete_repository_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.update_repository), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_repository(request) + response = await client.update_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = secure_source_manager.DeleteRepositoryRequest() + request = secure_source_manager.UpdateRepositoryRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -4183,27 +4179,27 @@ async def test_delete_repository_async( @pytest.mark.asyncio -async def test_delete_repository_async_from_dict(): - await test_delete_repository_async(request_type=dict) +async def test_update_repository_async_from_dict(): + await test_update_repository_async(request_type=dict) -def test_delete_repository_field_headers(): +def test_update_repository_field_headers(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = secure_source_manager.DeleteRepositoryRequest() + request = secure_source_manager.UpdateRepositoryRequest() - request.name = "name_value" + request.repository.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.update_repository), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_repository(request) + client.update_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -4214,30 +4210,30 @@ def test_delete_repository_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "repository.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_delete_repository_field_headers_async(): +async def test_update_repository_field_headers_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = secure_source_manager.DeleteRepositoryRequest() + request = secure_source_manager.UpdateRepositoryRequest() - request.name = "name_value" + request.repository.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.update_repository), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_repository(request) + await client.update_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -4248,37 +4244,41 @@ async def test_delete_repository_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "repository.name=name_value", ) in kw["metadata"] -def test_delete_repository_flattened(): +def test_update_repository_flattened(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.update_repository), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_repository( - name="name_value", + client.update_repository( + repository=secure_source_manager.Repository(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].repository + mock_val = secure_source_manager.Repository(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) assert arg == mock_val -def test_delete_repository_flattened_error(): +def test_update_repository_flattened_error(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -4286,21 +4286,22 @@ def test_delete_repository_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_repository( - secure_source_manager.DeleteRepositoryRequest(), - name="name_value", + client.update_repository( + secure_source_manager.UpdateRepositoryRequest(), + repository=secure_source_manager.Repository(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio -async def test_delete_repository_flattened_async(): +async def test_update_repository_flattened_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.update_repository), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -4310,21 +4311,25 @@ async def test_delete_repository_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_repository( - name="name_value", + response = await client.update_repository( + repository=secure_source_manager.Repository(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].repository + mock_val = secure_source_manager.Repository(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) assert arg == mock_val @pytest.mark.asyncio -async def test_delete_repository_flattened_error_async(): +async def test_update_repository_flattened_error_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) @@ -4332,20 +4337,21 @@ async def test_delete_repository_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.delete_repository( - secure_source_manager.DeleteRepositoryRequest(), - name="name_value", + await client.update_repository( + secure_source_manager.UpdateRepositoryRequest(), + repository=secure_source_manager.Repository(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.GetIamPolicyRequest, + secure_source_manager.DeleteRepositoryRequest, dict, ], ) -def test_get_iam_policy_repo(request_type, transport: str = "grpc"): +def test_delete_repository(request_type, transport: str = "grpc"): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -4357,28 +4363,23 @@ def test_get_iam_policy_repo(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_iam_policy_repo), "__call__" + type(client.transport.delete_repository), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy( - version=774, - etag=b"etag_blob", - ) - response = client.get_iam_policy_repo(request) + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.delete_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = iam_policy_pb2.GetIamPolicyRequest() + request = secure_source_manager.DeleteRepositoryRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, policy_pb2.Policy) - assert response.version == 774 - assert response.etag == b"etag_blob" + assert isinstance(response, future.Future) -def test_get_iam_policy_repo_non_empty_request_with_auto_populated_field(): +def test_delete_repository_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = SecureSourceManagerClient( @@ -4389,26 +4390,26 @@ def test_get_iam_policy_repo_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", + request = secure_source_manager.DeleteRepositoryRequest( + name="name_value", ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_iam_policy_repo), "__call__" + type(client.transport.delete_repository), "__call__" ) as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.get_iam_policy_repo(request=request) + client.delete_repository(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.GetIamPolicyRequest( - resource="resource_value", + assert args[0] == secure_source_manager.DeleteRepositoryRequest( + name="name_value", ) -def test_get_iam_policy_repo_use_cached_wrapped_rpc(): +def test_delete_repository_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -4422,9 +4423,7 @@ def test_get_iam_policy_repo_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.get_iam_policy_repo in client._transport._wrapped_methods - ) + assert client._transport.delete_repository in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() @@ -4432,15 +4431,20 @@ def test_get_iam_policy_repo_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.get_iam_policy_repo + client._transport.delete_repository ] = mock_rpc request = {} - client.get_iam_policy_repo(request) + client.delete_repository(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_iam_policy_repo(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_repository(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -4448,7 +4452,7 @@ def test_get_iam_policy_repo_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_get_iam_policy_repo_async_use_cached_wrapped_rpc( +async def test_delete_repository_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -4465,7 +4469,7 @@ async def test_get_iam_policy_repo_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.get_iam_policy_repo + client._client._transport.delete_repository in client._client._transport._wrapped_methods ) @@ -4473,16 +4477,21 @@ async def test_get_iam_policy_repo_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.get_iam_policy_repo + client._client._transport.delete_repository ] = mock_rpc request = {} - await client.get_iam_policy_repo(request) + await client.delete_repository(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.get_iam_policy_repo(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.delete_repository(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -4490,8 +4499,9 @@ async def test_get_iam_policy_repo_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_get_iam_policy_repo_async( - transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest +async def test_delete_repository_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.DeleteRepositoryRequest, ): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), @@ -4504,51 +4514,46 @@ async def test_get_iam_policy_repo_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_iam_policy_repo), "__call__" + type(client.transport.delete_repository), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy( - version=774, - etag=b"etag_blob", - ) + operations_pb2.Operation(name="operations/spam") ) - response = await client.get_iam_policy_repo(request) + response = await client.delete_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = iam_policy_pb2.GetIamPolicyRequest() + request = secure_source_manager.DeleteRepositoryRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, policy_pb2.Policy) - assert response.version == 774 - assert response.etag == b"etag_blob" + assert isinstance(response, future.Future) @pytest.mark.asyncio -async def test_get_iam_policy_repo_async_from_dict(): - await test_get_iam_policy_repo_async(request_type=dict) +async def test_delete_repository_async_from_dict(): + await test_delete_repository_async(request_type=dict) -def test_get_iam_policy_repo_field_headers(): +def test_delete_repository_field_headers(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy_pb2.GetIamPolicyRequest() + request = secure_source_manager.DeleteRepositoryRequest() - request.resource = "resource_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_iam_policy_repo), "__call__" + type(client.transport.delete_repository), "__call__" ) as call: - call.return_value = policy_pb2.Policy() - client.get_iam_policy_repo(request) + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -4559,28 +4564,30 @@ def test_get_iam_policy_repo_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_get_iam_policy_repo_field_headers_async(): +async def test_delete_repository_field_headers_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy_pb2.GetIamPolicyRequest() + request = secure_source_manager.DeleteRepositoryRequest() - request.resource = "resource_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_iam_policy_repo), "__call__" + type(client.transport.delete_repository), "__call__" ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) - await client.get_iam_policy_repo(request) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.delete_repository(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -4591,56 +4598,37 @@ async def test_get_iam_policy_repo_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "name=name_value", ) in kw["metadata"] -def test_get_iam_policy_repo_from_dict_foreign(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_iam_policy_repo), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy() - response = client.get_iam_policy_repo( - request={ - "resource": "resource_value", - "options": options_pb2.GetPolicyOptions(requested_policy_version=2598), - } - ) - call.assert_called() - - -def test_get_iam_policy_repo_flattened(): +def test_delete_repository_flattened(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_iam_policy_repo), "__call__" + type(client.transport.delete_repository), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy() + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_iam_policy_repo( - resource="resource_value", + client.delete_repository( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].resource - mock_val = "resource_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_get_iam_policy_repo_flattened_error(): +def test_delete_repository_flattened_error(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -4648,43 +4636,45 @@ def test_get_iam_policy_repo_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_iam_policy_repo( - iam_policy_pb2.GetIamPolicyRequest(), - resource="resource_value", + client.delete_repository( + secure_source_manager.DeleteRepositoryRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_get_iam_policy_repo_flattened_async(): +async def test_delete_repository_flattened_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.get_iam_policy_repo), "__call__" + type(client.transport.delete_repository), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy() + call.return_value = operations_pb2.Operation(name="operations/op") - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_iam_policy_repo( - resource="resource_value", + response = await client.delete_repository( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].resource - mock_val = "resource_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_get_iam_policy_repo_flattened_error_async(): +async def test_delete_repository_flattened_error_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) @@ -4692,20 +4682,20 @@ async def test_get_iam_policy_repo_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_iam_policy_repo( - iam_policy_pb2.GetIamPolicyRequest(), - resource="resource_value", + await client.delete_repository( + secure_source_manager.DeleteRepositoryRequest(), + name="name_value", ) @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.SetIamPolicyRequest, + secure_source_manager.ListHooksRequest, dict, ], ) -def test_set_iam_policy_repo(request_type, transport: str = "grpc"): +def test_list_hooks(request_type, transport: str = "grpc"): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -4716,29 +4706,25 @@ def test_set_iam_policy_repo(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy_repo), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_hooks), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy( - version=774, - etag=b"etag_blob", + call.return_value = secure_source_manager.ListHooksResponse( + next_page_token="next_page_token_value", ) - response = client.set_iam_policy_repo(request) + response = client.list_hooks(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = iam_policy_pb2.SetIamPolicyRequest() + request = secure_source_manager.ListHooksRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, policy_pb2.Policy) - assert response.version == 774 - assert response.etag == b"etag_blob" + assert isinstance(response, pagers.ListHooksPager) + assert response.next_page_token == "next_page_token_value" -def test_set_iam_policy_repo_non_empty_request_with_auto_populated_field(): +def test_list_hooks_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = SecureSourceManagerClient( @@ -4749,26 +4735,26 @@ def test_set_iam_policy_repo_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", + request = secure_source_manager.ListHooksRequest( + parent="parent_value", + page_token="page_token_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy_repo), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_hooks), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.set_iam_policy_repo(request=request) + client.list_hooks(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.SetIamPolicyRequest( - resource="resource_value", + assert args[0] == secure_source_manager.ListHooksRequest( + parent="parent_value", + page_token="page_token_value", ) -def test_set_iam_policy_repo_use_cached_wrapped_rpc(): +def test_list_hooks_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -4782,25 +4768,21 @@ def test_set_iam_policy_repo_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.set_iam_policy_repo in client._transport._wrapped_methods - ) + assert client._transport.list_hooks in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.set_iam_policy_repo - ] = mock_rpc + client._transport._wrapped_methods[client._transport.list_hooks] = mock_rpc request = {} - client.set_iam_policy_repo(request) + client.list_hooks(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.set_iam_policy_repo(request) + client.list_hooks(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -4808,9 +4790,7 @@ def test_set_iam_policy_repo_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_set_iam_policy_repo_async_use_cached_wrapped_rpc( - transport: str = "grpc_asyncio", -): +async def test_list_hooks_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -4825,7 +4805,7 @@ async def test_set_iam_policy_repo_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.set_iam_policy_repo + client._client._transport.list_hooks in client._client._transport._wrapped_methods ) @@ -4833,16 +4813,16 @@ async def test_set_iam_policy_repo_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.set_iam_policy_repo + client._client._transport.list_hooks ] = mock_rpc request = {} - await client.set_iam_policy_repo(request) + await client.list_hooks(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.set_iam_policy_repo(request) + await client.list_hooks(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -4850,8 +4830,8 @@ async def test_set_iam_policy_repo_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_set_iam_policy_repo_async( - transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest +async def test_list_hooks_async( + transport: str = "grpc_asyncio", request_type=secure_source_manager.ListHooksRequest ): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), @@ -4863,52 +4843,46 @@ async def test_set_iam_policy_repo_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy_repo), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_hooks), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy( - version=774, - etag=b"etag_blob", + secure_source_manager.ListHooksResponse( + next_page_token="next_page_token_value", ) ) - response = await client.set_iam_policy_repo(request) + response = await client.list_hooks(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = iam_policy_pb2.SetIamPolicyRequest() + request = secure_source_manager.ListHooksRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, policy_pb2.Policy) - assert response.version == 774 - assert response.etag == b"etag_blob" + assert isinstance(response, pagers.ListHooksAsyncPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.asyncio -async def test_set_iam_policy_repo_async_from_dict(): - await test_set_iam_policy_repo_async(request_type=dict) +async def test_list_hooks_async_from_dict(): + await test_list_hooks_async(request_type=dict) -def test_set_iam_policy_repo_field_headers(): +def test_list_hooks_field_headers(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy_pb2.SetIamPolicyRequest() + request = secure_source_manager.ListHooksRequest() - request.resource = "resource_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy_repo), "__call__" - ) as call: - call.return_value = policy_pb2.Policy() - client.set_iam_policy_repo(request) + with mock.patch.object(type(client.transport.list_hooks), "__call__") as call: + call.return_value = secure_source_manager.ListHooksResponse() + client.list_hooks(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -4919,28 +4893,28 @@ def test_set_iam_policy_repo_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "parent=parent_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_set_iam_policy_repo_field_headers_async(): +async def test_list_hooks_field_headers_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy_pb2.SetIamPolicyRequest() + request = secure_source_manager.ListHooksRequest() - request.resource = "resource_value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy_repo), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) - await client.set_iam_policy_repo(request) + with mock.patch.object(type(client.transport.list_hooks), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListHooksResponse() + ) + await client.list_hooks(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -4951,57 +4925,35 @@ async def test_set_iam_policy_repo_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "parent=parent_value", ) in kw["metadata"] -def test_set_iam_policy_repo_from_dict_foreign(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy_repo), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy() - response = client.set_iam_policy_repo( - request={ - "resource": "resource_value", - "policy": policy_pb2.Policy(version=774), - "update_mask": field_mask_pb2.FieldMask(paths=["paths_value"]), - } - ) - call.assert_called() - - -def test_set_iam_policy_repo_flattened(): +def test_list_hooks_flattened(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy_repo), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_hooks), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy() + call.return_value = secure_source_manager.ListHooksResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.set_iam_policy_repo( - resource="resource_value", + client.list_hooks( + parent="parent_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].resource - mock_val = "resource_value" + arg = args[0].parent + mock_val = "parent_value" assert arg == mock_val -def test_set_iam_policy_repo_flattened_error(): +def test_list_hooks_flattened_error(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -5009,43 +4961,43 @@ def test_set_iam_policy_repo_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.set_iam_policy_repo( - iam_policy_pb2.SetIamPolicyRequest(), - resource="resource_value", + client.list_hooks( + secure_source_manager.ListHooksRequest(), + parent="parent_value", ) @pytest.mark.asyncio -async def test_set_iam_policy_repo_flattened_async(): +async def test_list_hooks_flattened_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy_repo), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_hooks), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy() + call.return_value = secure_source_manager.ListHooksResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListHooksResponse() + ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.set_iam_policy_repo( - resource="resource_value", + response = await client.list_hooks( + parent="parent_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].resource - mock_val = "resource_value" + arg = args[0].parent + mock_val = "parent_value" assert arg == mock_val @pytest.mark.asyncio -async def test_set_iam_policy_repo_flattened_error_async(): +async def test_list_hooks_flattened_error_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) @@ -5053,81 +5005,281 @@ async def test_set_iam_policy_repo_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.set_iam_policy_repo( - iam_policy_pb2.SetIamPolicyRequest(), - resource="resource_value", + await client.list_hooks( + secure_source_manager.ListHooksRequest(), + parent="parent_value", ) -@pytest.mark.parametrize( - "request_type", - [ - iam_policy_pb2.TestIamPermissionsRequest, - dict, - ], -) -def test_test_iam_permissions_repo(request_type, transport: str = "grpc"): +def test_list_hooks_pager(transport_name: str = "grpc"): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport=transport_name, ) - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions_repo), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = iam_policy_pb2.TestIamPermissionsResponse( - permissions=["permissions_value"], + with mock.patch.object(type(client.transport.list_hooks), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + secure_source_manager.Hook(), + secure_source_manager.Hook(), + ], + next_page_token="abc", + ), + secure_source_manager.ListHooksResponse( + hooks=[], + next_page_token="def", + ), + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + secure_source_manager.Hook(), + ], + ), + RuntimeError, ) - response = client.test_iam_permissions_repo(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = iam_policy_pb2.TestIamPermissionsRequest() - assert args[0] == request + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_hooks(request={}, retry=retry, timeout=timeout) - # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) - assert response.permissions == ["permissions_value"] + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.Hook) for i in results) -def test_test_iam_permissions_repo_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. + +def test_list_hooks_pages(transport_name: str = "grpc"): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport_name, ) - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_hooks), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + secure_source_manager.Hook(), + secure_source_manager.Hook(), + ], + next_page_token="abc", + ), + secure_source_manager.ListHooksResponse( + hooks=[], + next_page_token="def", + ), + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + secure_source_manager.Hook(), + ], + ), + RuntimeError, + ) + pages = list(client.list_hooks(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_hooks_async_pager(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.test_iam_permissions_repo), "__call__" + type(client.transport.list_hooks), "__call__", new_callable=mock.AsyncMock ) as call: - call.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + secure_source_manager.Hook(), + secure_source_manager.Hook(), + ], + next_page_token="abc", + ), + secure_source_manager.ListHooksResponse( + hooks=[], + next_page_token="def", + ), + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + secure_source_manager.Hook(), + ], + ), + RuntimeError, ) - client.test_iam_permissions_repo(request=request) + async_pager = await client.list_hooks( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, secure_source_manager.Hook) for i in responses) + + +@pytest.mark.asyncio +async def test_list_hooks_async_pages(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_hooks), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + secure_source_manager.Hook(), + secure_source_manager.Hook(), + ], + next_page_token="abc", + ), + secure_source_manager.ListHooksResponse( + hooks=[], + next_page_token="def", + ), + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + secure_source_manager.Hook(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_hooks(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetHookRequest, + dict, + ], +) +def test_get_hook(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_hook), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.Hook( + name="name_value", + target_uri="target_uri_value", + disabled=True, + events=[secure_source_manager.Hook.HookEventType.PUSH], + uid="uid_value", + sensitive_query_string="sensitive_query_string_value", + ) + response = client.get_hook(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.GetHookRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.Hook) + assert response.name == "name_value" + assert response.target_uri == "target_uri_value" + assert response.disabled is True + assert response.events == [secure_source_manager.Hook.HookEventType.PUSH] + assert response.uid == "uid_value" + assert response.sensitive_query_string == "sensitive_query_string_value" + + +def test_get_hook_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.GetHookRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_hook), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_hook(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == iam_policy_pb2.TestIamPermissionsRequest( - resource="resource_value", + assert args[0] == secure_source_manager.GetHookRequest( + name="name_value", ) -def test_test_iam_permissions_repo_use_cached_wrapped_rpc(): +def test_get_hook_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -5141,26 +5293,21 @@ def test_test_iam_permissions_repo_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.test_iam_permissions_repo - in client._transport._wrapped_methods - ) + assert client._transport.get_hook in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.test_iam_permissions_repo - ] = mock_rpc + client._transport._wrapped_methods[client._transport.get_hook] = mock_rpc request = {} - client.test_iam_permissions_repo(request) + client.get_hook(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.test_iam_permissions_repo(request) + client.get_hook(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -5168,9 +5315,7 @@ def test_test_iam_permissions_repo_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_test_iam_permissions_repo_async_use_cached_wrapped_rpc( - transport: str = "grpc_asyncio", -): +async def test_get_hook_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: @@ -5185,7 +5330,7 @@ async def test_test_iam_permissions_repo_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.test_iam_permissions_repo + client._client._transport.get_hook in client._client._transport._wrapped_methods ) @@ -5193,16 +5338,16 @@ async def test_test_iam_permissions_repo_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.test_iam_permissions_repo + client._client._transport.get_hook ] = mock_rpc request = {} - await client.test_iam_permissions_repo(request) + await client.get_hook(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.test_iam_permissions_repo(request) + await client.get_hook(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -5210,9 +5355,8 @@ async def test_test_iam_permissions_repo_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_test_iam_permissions_repo_async( - transport: str = "grpc_asyncio", - request_type=iam_policy_pb2.TestIamPermissionsRequest, +async def test_get_hook_async( + transport: str = "grpc_asyncio", request_type=secure_source_manager.GetHookRequest ): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), @@ -5224,50 +5368,56 @@ async def test_test_iam_permissions_repo_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions_repo), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_hook), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy_pb2.TestIamPermissionsResponse( - permissions=["permissions_value"], + secure_source_manager.Hook( + name="name_value", + target_uri="target_uri_value", + disabled=True, + events=[secure_source_manager.Hook.HookEventType.PUSH], + uid="uid_value", + sensitive_query_string="sensitive_query_string_value", ) ) - response = await client.test_iam_permissions_repo(request) + response = await client.get_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = iam_policy_pb2.TestIamPermissionsRequest() + request = secure_source_manager.GetHookRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) - assert response.permissions == ["permissions_value"] + assert isinstance(response, secure_source_manager.Hook) + assert response.name == "name_value" + assert response.target_uri == "target_uri_value" + assert response.disabled is True + assert response.events == [secure_source_manager.Hook.HookEventType.PUSH] + assert response.uid == "uid_value" + assert response.sensitive_query_string == "sensitive_query_string_value" @pytest.mark.asyncio -async def test_test_iam_permissions_repo_async_from_dict(): - await test_test_iam_permissions_repo_async(request_type=dict) +async def test_get_hook_async_from_dict(): + await test_get_hook_async(request_type=dict) -def test_test_iam_permissions_repo_field_headers(): +def test_get_hook_field_headers(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy_pb2.TestIamPermissionsRequest() + request = secure_source_manager.GetHookRequest() - request.resource = "resource_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions_repo), "__call__" - ) as call: - call.return_value = iam_policy_pb2.TestIamPermissionsResponse() - client.test_iam_permissions_repo(request) + with mock.patch.object(type(client.transport.get_hook), "__call__") as call: + call.return_value = secure_source_manager.Hook() + client.get_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -5278,30 +5428,28 @@ def test_test_iam_permissions_repo_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_test_iam_permissions_repo_field_headers_async(): +async def test_get_hook_field_headers_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = iam_policy_pb2.TestIamPermissionsRequest() + request = secure_source_manager.GetHookRequest() - request.resource = "resource_value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions_repo), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_hook), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy_pb2.TestIamPermissionsResponse() + secure_source_manager.Hook() ) - await client.test_iam_permissions_repo(request) + await client.get_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -5312,56 +5460,35 @@ async def test_test_iam_permissions_repo_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource_value", + "name=name_value", ) in kw["metadata"] -def test_test_iam_permissions_repo_from_dict_foreign(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions_repo), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = iam_policy_pb2.TestIamPermissionsResponse() - response = client.test_iam_permissions_repo( - request={ - "resource": "resource_value", - "permissions": ["permissions_value"], - } - ) - call.assert_called() - - -def test_test_iam_permissions_repo_flattened(): +def test_get_hook_flattened(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions_repo), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_hook), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = iam_policy_pb2.TestIamPermissionsResponse() + call.return_value = secure_source_manager.Hook() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.test_iam_permissions_repo( - resource="resource_value", + client.get_hook( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].resource - mock_val = "resource_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val -def test_test_iam_permissions_repo_flattened_error(): +def test_get_hook_flattened_error(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -5369,45 +5496,43 @@ def test_test_iam_permissions_repo_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.test_iam_permissions_repo( - iam_policy_pb2.TestIamPermissionsRequest(), - resource="resource_value", + client.get_hook( + secure_source_manager.GetHookRequest(), + name="name_value", ) @pytest.mark.asyncio -async def test_test_iam_permissions_repo_flattened_async(): +async def test_get_hook_flattened_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions_repo), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_hook), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = iam_policy_pb2.TestIamPermissionsResponse() + call.return_value = secure_source_manager.Hook() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy_pb2.TestIamPermissionsResponse() + secure_source_manager.Hook() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.test_iam_permissions_repo( - resource="resource_value", + response = await client.get_hook( + name="name_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].resource - mock_val = "resource_value" + arg = args[0].name + mock_val = "name_value" assert arg == mock_val @pytest.mark.asyncio -async def test_test_iam_permissions_repo_flattened_error_async(): +async def test_get_hook_flattened_error_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) @@ -5415,20 +5540,20 @@ async def test_test_iam_permissions_repo_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.test_iam_permissions_repo( - iam_policy_pb2.TestIamPermissionsRequest(), - resource="resource_value", + await client.get_hook( + secure_source_manager.GetHookRequest(), + name="name_value", ) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.CreateBranchRuleRequest, + secure_source_manager.CreateHookRequest, dict, ], ) -def test_create_branch_rule(request_type, transport: str = "grpc"): +def test_create_hook(request_type, transport: str = "grpc"): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -5439,24 +5564,22 @@ def test_create_branch_rule(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_branch_rule), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_hook), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_branch_rule(request) + response = client.create_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = secure_source_manager.CreateBranchRuleRequest() + request = secure_source_manager.CreateHookRequest() assert args[0] == request # Establish that the response is the type that we expect. assert isinstance(response, future.Future) -def test_create_branch_rule_non_empty_request_with_auto_populated_field(): +def test_create_hook_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = SecureSourceManagerClient( @@ -5467,28 +5590,26 @@ def test_create_branch_rule_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = secure_source_manager.CreateBranchRuleRequest( + request = secure_source_manager.CreateHookRequest( parent="parent_value", - branch_rule_id="branch_rule_id_value", + hook_id="hook_id_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_branch_rule), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_hook), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.create_branch_rule(request=request) + client.create_hook(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == secure_source_manager.CreateBranchRuleRequest( + assert args[0] == secure_source_manager.CreateHookRequest( parent="parent_value", - branch_rule_id="branch_rule_id_value", + hook_id="hook_id_value", ) -def test_create_branch_rule_use_cached_wrapped_rpc(): +def test_create_hook_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -5502,20 +5623,16 @@ def test_create_branch_rule_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert ( - client._transport.create_branch_rule in client._transport._wrapped_methods - ) + assert client._transport.create_hook in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.create_branch_rule - ] = mock_rpc + client._transport._wrapped_methods[client._transport.create_hook] = mock_rpc request = {} - client.create_branch_rule(request) + client.create_hook(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -5525,7 +5642,7 @@ def test_create_branch_rule_use_cached_wrapped_rpc(): # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - client.create_branch_rule(request) + client.create_hook(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -5533,7 +5650,7 @@ def test_create_branch_rule_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_create_branch_rule_async_use_cached_wrapped_rpc( +async def test_create_hook_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -5550,7 +5667,7 @@ async def test_create_branch_rule_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.create_branch_rule + client._client._transport.create_hook in client._client._transport._wrapped_methods ) @@ -5558,11 +5675,11 @@ async def test_create_branch_rule_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.create_branch_rule + client._client._transport.create_hook ] = mock_rpc request = {} - await client.create_branch_rule(request) + await client.create_hook(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 @@ -5572,7 +5689,7 @@ async def test_create_branch_rule_async_use_cached_wrapped_rpc( # Subsequent calls should use the cached wrapper wrapper_fn.reset_mock() - await client.create_branch_rule(request) + await client.create_hook(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -5580,9 +5697,9 @@ async def test_create_branch_rule_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_create_branch_rule_async( +async def test_create_hook_async( transport: str = "grpc_asyncio", - request_type=secure_source_manager.CreateBranchRuleRequest, + request_type=secure_source_manager.CreateHookRequest, ): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), @@ -5594,19 +5711,17 @@ async def test_create_branch_rule_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_branch_rule), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_hook), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_branch_rule(request) + response = await client.create_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = secure_source_manager.CreateBranchRuleRequest() + request = secure_source_manager.CreateHookRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -5614,27 +5729,25 @@ async def test_create_branch_rule_async( @pytest.mark.asyncio -async def test_create_branch_rule_async_from_dict(): - await test_create_branch_rule_async(request_type=dict) +async def test_create_hook_async_from_dict(): + await test_create_hook_async(request_type=dict) -def test_create_branch_rule_field_headers(): +def test_create_hook_field_headers(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = secure_source_manager.CreateBranchRuleRequest() + request = secure_source_manager.CreateHookRequest() request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_branch_rule), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_hook), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_branch_rule(request) + client.create_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -5650,25 +5763,23 @@ def test_create_branch_rule_field_headers(): @pytest.mark.asyncio -async def test_create_branch_rule_field_headers_async(): +async def test_create_hook_field_headers_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = secure_source_manager.CreateBranchRuleRequest() + request = secure_source_manager.CreateHookRequest() request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_branch_rule), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_hook), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_branch_rule(request) + await client.create_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -5683,23 +5794,21 @@ async def test_create_branch_rule_field_headers_async(): ) in kw["metadata"] -def test_create_branch_rule_flattened(): +def test_create_hook_flattened(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_branch_rule), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_hook), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.create_branch_rule( + client.create_hook( parent="parent_value", - branch_rule=secure_source_manager.BranchRule(name="name_value"), - branch_rule_id="branch_rule_id_value", + hook=secure_source_manager.Hook(name="name_value"), + hook_id="hook_id_value", ) # Establish that the underlying call was made with the expected @@ -5709,15 +5818,15 @@ def test_create_branch_rule_flattened(): arg = args[0].parent mock_val = "parent_value" assert arg == mock_val - arg = args[0].branch_rule - mock_val = secure_source_manager.BranchRule(name="name_value") + arg = args[0].hook + mock_val = secure_source_manager.Hook(name="name_value") assert arg == mock_val - arg = args[0].branch_rule_id - mock_val = "branch_rule_id_value" + arg = args[0].hook_id + mock_val = "hook_id_value" assert arg == mock_val -def test_create_branch_rule_flattened_error(): +def test_create_hook_flattened_error(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -5725,24 +5834,22 @@ def test_create_branch_rule_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.create_branch_rule( - secure_source_manager.CreateBranchRuleRequest(), + client.create_hook( + secure_source_manager.CreateHookRequest(), parent="parent_value", - branch_rule=secure_source_manager.BranchRule(name="name_value"), - branch_rule_id="branch_rule_id_value", + hook=secure_source_manager.Hook(name="name_value"), + hook_id="hook_id_value", ) @pytest.mark.asyncio -async def test_create_branch_rule_flattened_async(): +async def test_create_hook_flattened_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_branch_rule), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_hook), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -5751,10 +5858,10 @@ async def test_create_branch_rule_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.create_branch_rule( + response = await client.create_hook( parent="parent_value", - branch_rule=secure_source_manager.BranchRule(name="name_value"), - branch_rule_id="branch_rule_id_value", + hook=secure_source_manager.Hook(name="name_value"), + hook_id="hook_id_value", ) # Establish that the underlying call was made with the expected @@ -5764,16 +5871,16 @@ async def test_create_branch_rule_flattened_async(): arg = args[0].parent mock_val = "parent_value" assert arg == mock_val - arg = args[0].branch_rule - mock_val = secure_source_manager.BranchRule(name="name_value") + arg = args[0].hook + mock_val = secure_source_manager.Hook(name="name_value") assert arg == mock_val - arg = args[0].branch_rule_id - mock_val = "branch_rule_id_value" + arg = args[0].hook_id + mock_val = "hook_id_value" assert arg == mock_val @pytest.mark.asyncio -async def test_create_branch_rule_flattened_error_async(): +async def test_create_hook_flattened_error_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) @@ -5781,22 +5888,22 @@ async def test_create_branch_rule_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.create_branch_rule( - secure_source_manager.CreateBranchRuleRequest(), + await client.create_hook( + secure_source_manager.CreateHookRequest(), parent="parent_value", - branch_rule=secure_source_manager.BranchRule(name="name_value"), - branch_rule_id="branch_rule_id_value", + hook=secure_source_manager.Hook(name="name_value"), + hook_id="hook_id_value", ) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.ListBranchRulesRequest, + secure_source_manager.UpdateHookRequest, dict, ], ) -def test_list_branch_rules(request_type, transport: str = "grpc"): +def test_update_hook(request_type, transport: str = "grpc"): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -5807,27 +5914,22 @@ def test_list_branch_rules(request_type, transport: str = "grpc"): request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_branch_rules), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_hook), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = secure_source_manager.ListBranchRulesResponse( - next_page_token="next_page_token_value", - ) - response = client.list_branch_rules(request) + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.update_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = secure_source_manager.ListBranchRulesRequest() + request = secure_source_manager.UpdateHookRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBranchRulesPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, future.Future) -def test_list_branch_rules_non_empty_request_with_auto_populated_field(): +def test_update_hook_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = SecureSourceManagerClient( @@ -5838,28 +5940,20 @@ def test_list_branch_rules_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = secure_source_manager.ListBranchRulesRequest( - parent="parent_value", - page_token="page_token_value", - ) + request = secure_source_manager.UpdateHookRequest() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_branch_rules), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_hook), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.list_branch_rules(request=request) + client.update_hook(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == secure_source_manager.ListBranchRulesRequest( - parent="parent_value", - page_token="page_token_value", - ) + assert args[0] == secure_source_manager.UpdateHookRequest() -def test_list_branch_rules_use_cached_wrapped_rpc(): +def test_update_hook_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -5873,23 +5967,26 @@ def test_list_branch_rules_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_branch_rules in client._transport._wrapped_methods + assert client._transport.update_hook in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[ - client._transport.list_branch_rules - ] = mock_rpc + client._transport._wrapped_methods[client._transport.update_hook] = mock_rpc request = {} - client.list_branch_rules(request) + client.update_hook(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_branch_rules(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_hook(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -5897,7 +5994,7 @@ def test_list_branch_rules_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_list_branch_rules_async_use_cached_wrapped_rpc( +async def test_update_hook_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -5914,7 +6011,7 @@ async def test_list_branch_rules_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.list_branch_rules + client._client._transport.update_hook in client._client._transport._wrapped_methods ) @@ -5922,16 +6019,21 @@ async def test_list_branch_rules_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.list_branch_rules + client._client._transport.update_hook ] = mock_rpc request = {} - await client.list_branch_rules(request) + await client.update_hook(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.list_branch_rules(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.update_hook(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -5939,9 +6041,9 @@ async def test_list_branch_rules_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_list_branch_rules_async( +async def test_update_hook_async( transport: str = "grpc_asyncio", - request_type=secure_source_manager.ListBranchRulesRequest, + request_type=secure_source_manager.UpdateHookRequest, ): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), @@ -5953,50 +6055,43 @@ async def test_list_branch_rules_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_branch_rules), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_hook), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - secure_source_manager.ListBranchRulesResponse( - next_page_token="next_page_token_value", - ) + operations_pb2.Operation(name="operations/spam") ) - response = await client.list_branch_rules(request) + response = await client.update_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = secure_source_manager.ListBranchRulesRequest() + request = secure_source_manager.UpdateHookRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBranchRulesAsyncPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, future.Future) @pytest.mark.asyncio -async def test_list_branch_rules_async_from_dict(): - await test_list_branch_rules_async(request_type=dict) +async def test_update_hook_async_from_dict(): + await test_update_hook_async(request_type=dict) -def test_list_branch_rules_field_headers(): +def test_update_hook_field_headers(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = secure_source_manager.ListBranchRulesRequest() + request = secure_source_manager.UpdateHookRequest() - request.parent = "parent_value" + request.hook.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_branch_rules), "__call__" - ) as call: - call.return_value = secure_source_manager.ListBranchRulesResponse() - client.list_branch_rules(request) + with mock.patch.object(type(client.transport.update_hook), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -6007,30 +6102,28 @@ def test_list_branch_rules_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "hook.name=name_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_list_branch_rules_field_headers_async(): +async def test_update_hook_field_headers_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = secure_source_manager.ListBranchRulesRequest() + request = secure_source_manager.UpdateHookRequest() - request.parent = "parent_value" + request.hook.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_branch_rules), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_hook), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - secure_source_manager.ListBranchRulesResponse() + operations_pb2.Operation(name="operations/op") ) - await client.list_branch_rules(request) + await client.update_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -6041,37 +6134,39 @@ async def test_list_branch_rules_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent_value", + "hook.name=name_value", ) in kw["metadata"] -def test_list_branch_rules_flattened(): +def test_update_hook_flattened(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_branch_rules), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_hook), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = secure_source_manager.ListBranchRulesResponse() + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_branch_rules( - parent="parent_value", + client.update_hook( + hook=secure_source_manager.Hook(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" + arg = args[0].hook + mock_val = secure_source_manager.Hook(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) assert arg == mock_val -def test_list_branch_rules_flattened_error(): +def test_update_hook_flattened_error(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -6079,45 +6174,48 @@ def test_list_branch_rules_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_branch_rules( - secure_source_manager.ListBranchRulesRequest(), - parent="parent_value", + client.update_hook( + secure_source_manager.UpdateHookRequest(), + hook=secure_source_manager.Hook(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio -async def test_list_branch_rules_flattened_async(): +async def test_update_hook_flattened_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_branch_rules), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_hook), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = secure_source_manager.ListBranchRulesResponse() + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - secure_source_manager.ListBranchRulesResponse() + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_branch_rules( - parent="parent_value", + response = await client.update_hook( + hook=secure_source_manager.Hook(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = "parent_value" + arg = args[0].hook + mock_val = secure_source_manager.Hook(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) assert arg == mock_val @pytest.mark.asyncio -async def test_list_branch_rules_flattened_error_async(): +async def test_update_hook_flattened_error_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) @@ -6125,299 +6223,75 @@ async def test_list_branch_rules_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.list_branch_rules( - secure_source_manager.ListBranchRulesRequest(), - parent="parent_value", + await client.update_hook( + secure_source_manager.UpdateHookRequest(), + hook=secure_source_manager.Hook(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) -def test_list_branch_rules_pager(transport_name: str = "grpc"): +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.DeleteHookRequest, + dict, + ], +) +def test_delete_hook(request_type, transport: str = "grpc"): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, + transport=transport, ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_branch_rules), "__call__" - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - ], - next_page_token="abc", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[], - next_page_token="def", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - ], - next_page_token="ghi", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - ], - ), - RuntimeError, - ) + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), - ) - pager = client.list_branch_rules(request={}, retry=retry, timeout=timeout) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_hook), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.delete_hook(request) - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.DeleteHookRequest() + assert args[0] == request - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, secure_source_manager.BranchRule) for i in results) + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) -def test_list_branch_rules_pages(transport_name: str = "grpc"): +def test_delete_hook_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.DeleteHookRequest( + name="name_value", ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_branch_rules), "__call__" - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - ], - next_page_token="abc", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[], - next_page_token="def", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - ], - next_page_token="ghi", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - ], - ), - RuntimeError, - ) - pages = list(client.list_branch_rules(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.asyncio -async def test_list_branch_rules_async_pager(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_branch_rules), - "__call__", - new_callable=mock.AsyncMock, - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - ], - next_page_token="abc", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[], - next_page_token="def", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - ], - next_page_token="ghi", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_branch_rules( - request={}, - ) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, secure_source_manager.BranchRule) for i in responses) - - -@pytest.mark.asyncio -async def test_list_branch_rules_async_pages(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_branch_rules), - "__call__", - new_callable=mock.AsyncMock, - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - ], - next_page_token="abc", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[], - next_page_token="def", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - ], - next_page_token="ghi", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_branch_rules(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize( - "request_type", - [ - secure_source_manager.GetBranchRuleRequest, - dict, - ], -) -def test_get_branch_rule(request_type, transport: str = "grpc"): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = secure_source_manager.BranchRule( - name="name_value", - uid="uid_value", - etag="etag_value", - include_pattern="include_pattern_value", - disabled=True, - require_pull_request=True, - minimum_reviews_count=2280, - minimum_approvals_count=2491, - require_comments_resolved=True, - allow_stale_reviews=True, - require_linear_history=True, - ) - response = client.get_branch_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = secure_source_manager.GetBranchRuleRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, secure_source_manager.BranchRule) - assert response.name == "name_value" - assert response.uid == "uid_value" - assert response.etag == "etag_value" - assert response.include_pattern == "include_pattern_value" - assert response.disabled is True - assert response.require_pull_request is True - assert response.minimum_reviews_count == 2280 - assert response.minimum_approvals_count == 2491 - assert response.require_comments_resolved is True - assert response.allow_stale_reviews is True - assert response.require_linear_history is True - - -def test_get_branch_rule_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = secure_source_manager.GetBranchRuleRequest( - name="name_value", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + with mock.patch.object(type(client.transport.delete_hook), "__call__") as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.get_branch_rule(request=request) + client.delete_hook(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == secure_source_manager.GetBranchRuleRequest( + assert args[0] == secure_source_manager.DeleteHookRequest( name="name_value", ) -def test_get_branch_rule_use_cached_wrapped_rpc(): +def test_delete_hook_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -6431,21 +6305,26 @@ def test_get_branch_rule_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_branch_rule in client._transport._wrapped_methods + assert client._transport.delete_hook in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_branch_rule] = mock_rpc + client._transport._wrapped_methods[client._transport.delete_hook] = mock_rpc request = {} - client.get_branch_rule(request) + client.delete_hook(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_branch_rule(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_hook(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -6453,7 +6332,7 @@ def test_get_branch_rule_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_get_branch_rule_async_use_cached_wrapped_rpc( +async def test_delete_hook_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -6470,7 +6349,7 @@ async def test_get_branch_rule_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.get_branch_rule + client._client._transport.delete_hook in client._client._transport._wrapped_methods ) @@ -6478,16 +6357,21 @@ async def test_get_branch_rule_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.get_branch_rule + client._client._transport.delete_hook ] = mock_rpc request = {} - await client.get_branch_rule(request) + await client.delete_hook(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - await client.get_branch_rule(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.delete_hook(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -6495,9 +6379,9 @@ async def test_get_branch_rule_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_get_branch_rule_async( +async def test_delete_hook_async( transport: str = "grpc_asyncio", - request_type=secure_source_manager.GetBranchRuleRequest, + request_type=secure_source_manager.DeleteHookRequest, ): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), @@ -6509,66 +6393,43 @@ async def test_get_branch_rule_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + with mock.patch.object(type(client.transport.delete_hook), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - secure_source_manager.BranchRule( - name="name_value", - uid="uid_value", - etag="etag_value", - include_pattern="include_pattern_value", - disabled=True, - require_pull_request=True, - minimum_reviews_count=2280, - minimum_approvals_count=2491, - require_comments_resolved=True, - allow_stale_reviews=True, - require_linear_history=True, - ) + operations_pb2.Operation(name="operations/spam") ) - response = await client.get_branch_rule(request) + response = await client.delete_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = secure_source_manager.GetBranchRuleRequest() + request = secure_source_manager.DeleteHookRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, secure_source_manager.BranchRule) - assert response.name == "name_value" - assert response.uid == "uid_value" - assert response.etag == "etag_value" - assert response.include_pattern == "include_pattern_value" - assert response.disabled is True - assert response.require_pull_request is True - assert response.minimum_reviews_count == 2280 - assert response.minimum_approvals_count == 2491 - assert response.require_comments_resolved is True - assert response.allow_stale_reviews is True - assert response.require_linear_history is True + assert isinstance(response, future.Future) @pytest.mark.asyncio -async def test_get_branch_rule_async_from_dict(): - await test_get_branch_rule_async(request_type=dict) +async def test_delete_hook_async_from_dict(): + await test_delete_hook_async(request_type=dict) -def test_get_branch_rule_field_headers(): +def test_delete_hook_field_headers(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = secure_source_manager.GetBranchRuleRequest() + request = secure_source_manager.DeleteHookRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: - call.return_value = secure_source_manager.BranchRule() - client.get_branch_rule(request) + with mock.patch.object(type(client.transport.delete_hook), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -6584,23 +6445,23 @@ def test_get_branch_rule_field_headers(): @pytest.mark.asyncio -async def test_get_branch_rule_field_headers_async(): +async def test_delete_hook_field_headers_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = secure_source_manager.GetBranchRuleRequest() + request = secure_source_manager.DeleteHookRequest() request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + with mock.patch.object(type(client.transport.delete_hook), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - secure_source_manager.BranchRule() + operations_pb2.Operation(name="operations/op") ) - await client.get_branch_rule(request) + await client.delete_hook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -6615,18 +6476,18 @@ async def test_get_branch_rule_field_headers_async(): ) in kw["metadata"] -def test_get_branch_rule_flattened(): +def test_delete_hook_flattened(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + with mock.patch.object(type(client.transport.delete_hook), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = secure_source_manager.BranchRule() + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_branch_rule( + client.delete_hook( name="name_value", ) @@ -6639,7 +6500,7 @@ def test_get_branch_rule_flattened(): assert arg == mock_val -def test_get_branch_rule_flattened_error(): +def test_delete_hook_flattened_error(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -6647,29 +6508,29 @@ def test_get_branch_rule_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_branch_rule( - secure_source_manager.GetBranchRuleRequest(), + client.delete_hook( + secure_source_manager.DeleteHookRequest(), name="name_value", ) @pytest.mark.asyncio -async def test_get_branch_rule_flattened_async(): +async def test_delete_hook_flattened_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + with mock.patch.object(type(client.transport.delete_hook), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = secure_source_manager.BranchRule() + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - secure_source_manager.BranchRule() + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_branch_rule( + response = await client.delete_hook( name="name_value", ) @@ -6683,7 +6544,7 @@ async def test_get_branch_rule_flattened_async(): @pytest.mark.asyncio -async def test_get_branch_rule_flattened_error_async(): +async def test_delete_hook_flattened_error_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) @@ -6691,8 +6552,8 @@ async def test_get_branch_rule_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_branch_rule( - secure_source_manager.GetBranchRuleRequest(), + await client.delete_hook( + secure_source_manager.DeleteHookRequest(), name="name_value", ) @@ -6700,11 +6561,11 @@ async def test_get_branch_rule_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - secure_source_manager.UpdateBranchRuleRequest, + iam_policy_pb2.GetIamPolicyRequest, dict, ], ) -def test_update_branch_rule(request_type, transport: str = "grpc"): +def test_get_iam_policy_repo(request_type, transport: str = "grpc"): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -6716,23 +6577,28 @@ def test_update_branch_rule(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_branch_rule), "__call__" + type(client.transport.get_iam_policy_repo), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_branch_rule(request) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) + response = client.get_iam_policy_repo(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = secure_source_manager.UpdateBranchRuleRequest() + request = iam_policy_pb2.GetIamPolicyRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, policy_pb2.Policy) + assert response.version == 774 + assert response.etag == b"etag_blob" -def test_update_branch_rule_non_empty_request_with_auto_populated_field(): +def test_get_iam_policy_repo_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = SecureSourceManagerClient( @@ -6743,22 +6609,26 @@ def test_update_branch_rule_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = secure_source_manager.UpdateBranchRuleRequest() + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_branch_rule), "__call__" + type(client.transport.get_iam_policy_repo), "__call__" ) as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.update_branch_rule(request=request) + client.get_iam_policy_repo(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == secure_source_manager.UpdateBranchRuleRequest() + assert args[0] == iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) -def test_update_branch_rule_use_cached_wrapped_rpc(): +def test_get_iam_policy_repo_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -6773,7 +6643,7 @@ def test_update_branch_rule_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.update_branch_rule in client._transport._wrapped_methods + client._transport.get_iam_policy_repo in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -6782,20 +6652,15 @@ def test_update_branch_rule_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.update_branch_rule + client._transport.get_iam_policy_repo ] = mock_rpc request = {} - client.update_branch_rule(request) + client.get_iam_policy_repo(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.update_branch_rule(request) + client.get_iam_policy_repo(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -6803,7 +6668,7 @@ def test_update_branch_rule_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_update_branch_rule_async_use_cached_wrapped_rpc( +async def test_get_iam_policy_repo_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -6820,7 +6685,7 @@ async def test_update_branch_rule_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.update_branch_rule + client._client._transport.get_iam_policy_repo in client._client._transport._wrapped_methods ) @@ -6828,21 +6693,16 @@ async def test_update_branch_rule_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.update_branch_rule + client._client._transport.get_iam_policy_repo ] = mock_rpc request = {} - await client.update_branch_rule(request) + await client.get_iam_policy_repo(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.update_branch_rule(request) + await client.get_iam_policy_repo(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -6850,9 +6710,8 @@ async def test_update_branch_rule_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_update_branch_rule_async( - transport: str = "grpc_asyncio", - request_type=secure_source_manager.UpdateBranchRuleRequest, +async def test_get_iam_policy_repo_async( + transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), @@ -6865,46 +6724,51 @@ async def test_update_branch_rule_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_branch_rule), "__call__" + type(client.transport.get_iam_policy_repo), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) - response = await client.update_branch_rule(request) + response = await client.get_iam_policy_repo(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = secure_source_manager.UpdateBranchRuleRequest() + request = iam_policy_pb2.GetIamPolicyRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, policy_pb2.Policy) + assert response.version == 774 + assert response.etag == b"etag_blob" @pytest.mark.asyncio -async def test_update_branch_rule_async_from_dict(): - await test_update_branch_rule_async(request_type=dict) +async def test_get_iam_policy_repo_async_from_dict(): + await test_get_iam_policy_repo_async(request_type=dict) -def test_update_branch_rule_field_headers(): +def test_get_iam_policy_repo_field_headers(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = secure_source_manager.UpdateBranchRuleRequest() + request = iam_policy_pb2.GetIamPolicyRequest() - request.branch_rule.name = "name_value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_branch_rule), "__call__" + type(client.transport.get_iam_policy_repo), "__call__" ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.update_branch_rule(request) + call.return_value = policy_pb2.Policy() + client.get_iam_policy_repo(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -6915,30 +6779,28 @@ def test_update_branch_rule_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "branch_rule.name=name_value", + "resource=resource_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_update_branch_rule_field_headers_async(): +async def test_get_iam_policy_repo_field_headers_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = secure_source_manager.UpdateBranchRuleRequest() + request = iam_policy_pb2.GetIamPolicyRequest() - request.branch_rule.name = "name_value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_branch_rule), "__call__" + type(client.transport.get_iam_policy_repo), "__call__" ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.update_branch_rule(request) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) + await client.get_iam_policy_repo(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -6949,41 +6811,56 @@ async def test_update_branch_rule_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "branch_rule.name=name_value", + "resource=resource_value", ) in kw["metadata"] -def test_update_branch_rule_flattened(): +def test_get_iam_policy_repo_from_dict_foreign(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_iam_policy_repo), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = policy_pb2.Policy() + response = client.get_iam_policy_repo( + request={ + "resource": "resource_value", + "options": options_pb2.GetPolicyOptions(requested_policy_version=2598), + } + ) + call.assert_called() + + +def test_get_iam_policy_repo_flattened(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_branch_rule), "__call__" + type(client.transport.get_iam_policy_repo), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.update_branch_rule( - branch_rule=secure_source_manager.BranchRule(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.get_iam_policy_repo( + resource="resource_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].branch_rule - mock_val = secure_source_manager.BranchRule(name="name_value") - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].resource + mock_val = "resource_value" assert arg == mock_val -def test_update_branch_rule_flattened_error(): +def test_get_iam_policy_repo_flattened_error(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -6991,50 +6868,43 @@ def test_update_branch_rule_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.update_branch_rule( - secure_source_manager.UpdateBranchRuleRequest(), - branch_rule=secure_source_manager.BranchRule(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + client.get_iam_policy_repo( + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio -async def test_update_branch_rule_flattened_async(): +async def test_get_iam_policy_repo_flattened_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.update_branch_rule), "__call__" + type(client.transport.get_iam_policy_repo), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = policy_pb2.Policy() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.update_branch_rule( - branch_rule=secure_source_manager.BranchRule(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + response = await client.get_iam_policy_repo( + resource="resource_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].branch_rule - mock_val = secure_source_manager.BranchRule(name="name_value") - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].resource + mock_val = "resource_value" assert arg == mock_val @pytest.mark.asyncio -async def test_update_branch_rule_flattened_error_async(): +async def test_get_iam_policy_repo_flattened_error_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) @@ -7042,21 +6912,20 @@ async def test_update_branch_rule_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.update_branch_rule( - secure_source_manager.UpdateBranchRuleRequest(), - branch_rule=secure_source_manager.BranchRule(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + await client.get_iam_policy_repo( + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.DeleteBranchRuleRequest, + iam_policy_pb2.SetIamPolicyRequest, dict, ], ) -def test_delete_branch_rule(request_type, transport: str = "grpc"): +def test_set_iam_policy_repo(request_type, transport: str = "grpc"): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -7068,23 +6937,28 @@ def test_delete_branch_rule(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_branch_rule), "__call__" + type(client.transport.set_iam_policy_repo), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_branch_rule(request) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) + response = client.set_iam_policy_repo(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = secure_source_manager.DeleteBranchRuleRequest() + request = iam_policy_pb2.SetIamPolicyRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, policy_pb2.Policy) + assert response.version == 774 + assert response.etag == b"etag_blob" -def test_delete_branch_rule_non_empty_request_with_auto_populated_field(): +def test_set_iam_policy_repo_non_empty_request_with_auto_populated_field(): # This test is a coverage failsafe to make sure that UUID4 fields are # automatically populated, according to AIP-4235, with non-empty requests. client = SecureSourceManagerClient( @@ -7095,26 +6969,26 @@ def test_delete_branch_rule_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = secure_source_manager.DeleteBranchRuleRequest( - name="name_value", + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_branch_rule), "__call__" + type(client.transport.set_iam_policy_repo), "__call__" ) as call: call.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client.delete_branch_rule(request=request) + client.set_iam_policy_repo(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == secure_source_manager.DeleteBranchRuleRequest( - name="name_value", + assert args[0] == iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", ) -def test_delete_branch_rule_use_cached_wrapped_rpc(): +def test_set_iam_policy_repo_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: @@ -7129,7 +7003,7 @@ def test_delete_branch_rule_use_cached_wrapped_rpc(): # Ensure method has been cached assert ( - client._transport.delete_branch_rule in client._transport._wrapped_methods + client._transport.set_iam_policy_repo in client._transport._wrapped_methods ) # Replace cached wrapped function with mock @@ -7138,20 +7012,15 @@ def test_delete_branch_rule_use_cached_wrapped_rpc(): "foo" # operation_request.operation in compute client(s) expect a string. ) client._transport._wrapped_methods[ - client._transport.delete_branch_rule + client._transport.set_iam_policy_repo ] = mock_rpc request = {} - client.delete_branch_rule(request) + client.set_iam_policy_repo(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_branch_rule(request) + client.set_iam_policy_repo(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -7159,7 +7028,7 @@ def test_delete_branch_rule_use_cached_wrapped_rpc(): @pytest.mark.asyncio -async def test_delete_branch_rule_async_use_cached_wrapped_rpc( +async def test_set_iam_policy_repo_async_use_cached_wrapped_rpc( transport: str = "grpc_asyncio", ): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, @@ -7176,7 +7045,7 @@ async def test_delete_branch_rule_async_use_cached_wrapped_rpc( # Ensure method has been cached assert ( - client._client._transport.delete_branch_rule + client._client._transport.set_iam_policy_repo in client._client._transport._wrapped_methods ) @@ -7184,21 +7053,16 @@ async def test_delete_branch_rule_async_use_cached_wrapped_rpc( mock_rpc = mock.AsyncMock() mock_rpc.return_value = mock.Mock() client._client._transport._wrapped_methods[ - client._client._transport.delete_branch_rule + client._client._transport.set_iam_policy_repo ] = mock_rpc request = {} - await client.delete_branch_rule(request) + await client.set_iam_policy_repo(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_branch_rule(request) + await client.set_iam_policy_repo(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 @@ -7206,9 +7070,8 @@ async def test_delete_branch_rule_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_delete_branch_rule_async( - transport: str = "grpc_asyncio", - request_type=secure_source_manager.DeleteBranchRuleRequest, +async def test_set_iam_policy_repo_async( + transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), @@ -7221,46 +7084,51 @@ async def test_delete_branch_rule_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_branch_rule), "__call__" + type(client.transport.set_iam_policy_repo), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) - response = await client.delete_branch_rule(request) + response = await client.set_iam_policy_repo(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = secure_source_manager.DeleteBranchRuleRequest() + request = iam_policy_pb2.SetIamPolicyRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) + assert isinstance(response, policy_pb2.Policy) + assert response.version == 774 + assert response.etag == b"etag_blob" @pytest.mark.asyncio -async def test_delete_branch_rule_async_from_dict(): - await test_delete_branch_rule_async(request_type=dict) +async def test_set_iam_policy_repo_async_from_dict(): + await test_set_iam_policy_repo_async(request_type=dict) -def test_delete_branch_rule_field_headers(): +def test_set_iam_policy_repo_field_headers(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = secure_source_manager.DeleteBranchRuleRequest() + request = iam_policy_pb2.SetIamPolicyRequest() - request.name = "name_value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_branch_rule), "__call__" + type(client.transport.set_iam_policy_repo), "__call__" ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_branch_rule(request) + call.return_value = policy_pb2.Policy() + client.set_iam_policy_repo(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -7271,30 +7139,28 @@ def test_delete_branch_rule_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "resource=resource_value", ) in kw["metadata"] @pytest.mark.asyncio -async def test_delete_branch_rule_field_headers_async(): +async def test_set_iam_policy_repo_field_headers_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = secure_source_manager.DeleteBranchRuleRequest() + request = iam_policy_pb2.SetIamPolicyRequest() - request.name = "name_value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_branch_rule), "__call__" + type(client.transport.set_iam_policy_repo), "__call__" ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.delete_branch_rule(request) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) + await client.set_iam_policy_repo(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -7305,37 +7171,57 @@ async def test_delete_branch_rule_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name_value", + "resource=resource_value", ) in kw["metadata"] -def test_delete_branch_rule_flattened(): +def test_set_iam_policy_repo_from_dict_foreign(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.set_iam_policy_repo), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = policy_pb2.Policy() + response = client.set_iam_policy_repo( + request={ + "resource": "resource_value", + "policy": policy_pb2.Policy(version=774), + "update_mask": field_mask_pb2.FieldMask(paths=["paths_value"]), + } + ) + call.assert_called() + + +def test_set_iam_policy_repo_flattened(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_branch_rule), "__call__" + type(client.transport.set_iam_policy_repo), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_branch_rule( - name="name_value", + client.set_iam_policy_repo( + resource="resource_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].resource + mock_val = "resource_value" assert arg == mock_val -def test_delete_branch_rule_flattened_error(): +def test_set_iam_policy_repo_flattened_error(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -7343,45 +7229,43 @@ def test_delete_branch_rule_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_branch_rule( - secure_source_manager.DeleteBranchRuleRequest(), - name="name_value", + client.set_iam_policy_repo( + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio -async def test_delete_branch_rule_flattened_async(): +async def test_set_iam_policy_repo_flattened_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.delete_branch_rule), "__call__" + type(client.transport.set_iam_policy_repo), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") + call.return_value = policy_pb2.Policy() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_branch_rule( - name="name_value", + response = await client.set_iam_policy_repo( + resource="resource_value", ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" + arg = args[0].resource + mock_val = "resource_value" assert arg == mock_val @pytest.mark.asyncio -async def test_delete_branch_rule_flattened_error_async(): +async def test_set_iam_policy_repo_flattened_error_async(): client = SecureSourceManagerAsyncClient( credentials=async_anonymous_credentials(), ) @@ -7389,19 +7273,87 @@ async def test_delete_branch_rule_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.delete_branch_rule( - secure_source_manager.DeleteBranchRuleRequest(), - name="name_value", + await client.set_iam_policy_repo( + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) -def test_list_instances_rest_use_cached_wrapped_rpc(): +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.TestIamPermissionsRequest, + dict, + ], +) +def test_test_iam_permissions_repo(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions_repo), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = iam_policy_pb2.TestIamPermissionsResponse( + permissions=["permissions_value"], + ) + response = client.test_iam_permissions_repo(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = iam_policy_pb2.TestIamPermissionsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) + assert response.permissions == ["permissions_value"] + + +def test_test_iam_permissions_repo_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions_repo), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.test_iam_permissions_repo(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + ) + + +def test_test_iam_permissions_repo_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -7409,258 +7361,360 @@ def test_list_instances_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.list_instances in client._transport._wrapped_methods + assert ( + client._transport.test_iam_permissions_repo + in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.list_instances] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.test_iam_permissions_repo + ] = mock_rpc request = {} - client.list_instances(request) + client.test_iam_permissions_repo(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.list_instances(request) + client.test_iam_permissions_repo(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_list_instances_rest_required_fields( - request_type=secure_source_manager.ListInstancesRequest, +@pytest.mark.asyncio +async def test_test_iam_permissions_repo_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.SecureSourceManagerRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.test_iam_permissions_repo + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_instances._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.test_iam_permissions_repo + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.test_iam_permissions_repo(request) - jsonified_request["parent"] = "parent_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_instances._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "order_by", - "page_size", - "page_token", - ) + await client.test_iam_permissions_repo(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_test_iam_permissions_repo_async( + transport: str = "grpc_asyncio", + request_type=iam_policy_pb2.TestIamPermissionsRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions_repo), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + iam_policy_pb2.TestIamPermissionsResponse( + permissions=["permissions_value"], + ) + ) + response = await client.test_iam_permissions_repo(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = iam_policy_pb2.TestIamPermissionsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) + assert response.permissions == ["permissions_value"] + + +@pytest.mark.asyncio +async def test_test_iam_permissions_repo_async_from_dict(): + await test_test_iam_permissions_repo_async(request_type=dict) + +def test_test_iam_permissions_repo_field_headers(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = secure_source_manager.ListInstancesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = iam_policy_pb2.TestIamPermissionsRequest() - # Convert return value to protobuf type - return_value = secure_source_manager.ListInstancesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + request.resource = "resource_value" - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions_repo), "__call__" + ) as call: + call.return_value = iam_policy_pb2.TestIamPermissionsResponse() + client.test_iam_permissions_repo(request) - response = client.list_instances(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] -def test_list_instances_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials +@pytest.mark.asyncio +async def test_test_iam_permissions_repo_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), ) - unset_fields = transport.list_instances._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "filter", - "orderBy", - "pageSize", - "pageToken", - ) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = iam_policy_pb2.TestIamPermissionsRequest() + + request.resource = "resource_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions_repo), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + iam_policy_pb2.TestIamPermissionsResponse() ) - & set(("parent",)) - ) + await client.test_iam_permissions_repo(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request -def test_list_instances_rest_flattened(): + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] + + +def test_test_iam_permissions_repo_from_dict_foreign(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions_repo), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = iam_policy_pb2.TestIamPermissionsResponse() + response = client.test_iam_permissions_repo( + request={ + "resource": "resource_value", + "permissions": ["permissions_value"], + } + ) + call.assert_called() - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = secure_source_manager.ListInstancesResponse() - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} +def test_test_iam_permissions_repo_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions_repo), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = iam_policy_pb2.TestIamPermissionsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.test_iam_permissions_repo( + resource="resource_value", ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = secure_source_manager.ListInstancesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_instances(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/instances" % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].resource + mock_val = "resource_value" + assert arg == mock_val -def test_list_instances_rest_flattened_error(transport: str = "rest"): +def test_test_iam_permissions_repo_flattened_error(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_instances( - secure_source_manager.ListInstancesRequest(), - parent="parent_value", + client.test_iam_permissions_repo( + iam_policy_pb2.TestIamPermissionsRequest(), + resource="resource_value", ) -def test_list_instances_rest_pager(transport: str = "rest"): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - secure_source_manager.ListInstancesResponse( - instances=[ - secure_source_manager.Instance(), - secure_source_manager.Instance(), - secure_source_manager.Instance(), - ], - next_page_token="abc", - ), - secure_source_manager.ListInstancesResponse( - instances=[], - next_page_token="def", - ), - secure_source_manager.ListInstancesResponse( - instances=[ - secure_source_manager.Instance(), - ], - next_page_token="ghi", - ), - secure_source_manager.ListInstancesResponse( - instances=[ - secure_source_manager.Instance(), - secure_source_manager.Instance(), - ], - ), +@pytest.mark.asyncio +async def test_test_iam_permissions_repo_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions_repo), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = iam_policy_pb2.TestIamPermissionsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + iam_policy_pb2.TestIamPermissionsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.test_iam_permissions_repo( + resource="resource_value", ) - # Two responses for two calls - response = response + response - # Wrap the values into proper Response objs - response = tuple( - secure_source_manager.ListInstancesResponse.to_json(x) for x in response + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].resource + mock_val = "resource_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_test_iam_permissions_repo_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.test_iam_permissions_repo( + iam_policy_pb2.TestIamPermissionsRequest(), + resource="resource_value", ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - sample_request = {"parent": "projects/sample1/locations/sample2"} - pager = client.list_instances(request=sample_request) +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CreateBranchRuleRequest, + dict, + ], +) +def test_create_branch_rule(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, secure_source_manager.Instance) for i in results) + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - pages = list(client.list_instances(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.create_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.CreateBranchRuleRequest() + assert args[0] == request + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) -def test_get_instance_rest_use_cached_wrapped_rpc(): + +def test_create_branch_rule_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.CreateBranchRuleRequest( + parent="parent_value", + branch_rule_id="branch_rule_id_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_branch_rule), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_branch_rule(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.CreateBranchRuleRequest( + parent="parent_value", + branch_rule_id="branch_rule_id_value", + ) + + +def test_create_branch_rule_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -7668,393 +7722,370 @@ def test_get_instance_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_instance in client._transport._wrapped_methods + assert ( + client._transport.create_branch_rule in client._transport._wrapped_methods + ) # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_instance] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.create_branch_rule + ] = mock_rpc request = {} - client.get_instance(request) + client.create_branch_rule(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - client.get_instance(request) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_branch_rule(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_get_instance_rest_required_fields( - request_type=secure_source_manager.GetInstanceRequest, +@pytest.mark.asyncio +async def test_create_branch_rule_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.SecureSourceManagerRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.create_branch_rule + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_instance._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_branch_rule + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.create_branch_rule(request) - jsonified_request["name"] = "name_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_instance._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + await client.create_branch_rule(request) - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - # Designate an appropriate value for the returned response. - return_value = secure_source_manager.Instance() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = secure_source_manager.Instance.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) +@pytest.mark.asyncio +async def test_create_branch_rule_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.CreateBranchRuleRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response = client.get_instance(request) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.create_branch_rule(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.CreateBranchRuleRequest() + assert args[0] == request + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) -def test_get_instance_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - unset_fields = transport.get_instance._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) +@pytest.mark.asyncio +async def test_create_branch_rule_async_from_dict(): + await test_create_branch_rule_async(request_type=dict) -def test_get_instance_rest_flattened(): +def test_create_branch_rule_field_headers(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = secure_source_manager.Instance() + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.CreateBranchRuleRequest() - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/instances/sample3" - } + request.parent = "parent_value" - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_branch_rule), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_branch_rule_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.CreateBranchRuleRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_branch_rule), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") ) - mock_args.update(sample_request) + await client.create_branch_rule(request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = secure_source_manager.Instance.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - client.get_instance(**mock_args) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_branch_rule_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_branch_rule( + parent="parent_value", + branch_rule=secure_source_manager.BranchRule(name="name_value"), + branch_rule_id="branch_rule_id_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/instances/*}" % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].branch_rule + mock_val = secure_source_manager.BranchRule(name="name_value") + assert arg == mock_val + arg = args[0].branch_rule_id + mock_val = "branch_rule_id_value" + assert arg == mock_val -def test_get_instance_rest_flattened_error(transport: str = "rest"): +def test_create_branch_rule_flattened_error(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_instance( - secure_source_manager.GetInstanceRequest(), - name="name_value", + client.create_branch_rule( + secure_source_manager.CreateBranchRuleRequest(), + parent="parent_value", + branch_rule=secure_source_manager.BranchRule(name="name_value"), + branch_rule_id="branch_rule_id_value", ) -def test_create_instance_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() +@pytest.mark.asyncio +async def test_create_branch_rule_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Ensure method has been cached - assert client._transport.create_instance in client._transport._wrapped_methods + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_branch_rule( + parent="parent_value", + branch_rule=secure_source_manager.BranchRule(name="name_value"), + branch_rule_id="branch_rule_id_value", ) - client._transport._wrapped_methods[client._transport.create_instance] = mock_rpc - - request = {} - client.create_instance(request) - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].branch_rule + mock_val = secure_source_manager.BranchRule(name="name_value") + assert arg == mock_val + arg = args[0].branch_rule_id + mock_val = "branch_rule_id_value" + assert arg == mock_val - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - client.create_instance(request) +@pytest.mark.asyncio +async def test_create_branch_rule_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_branch_rule( + secure_source_manager.CreateBranchRuleRequest(), + parent="parent_value", + branch_rule=secure_source_manager.BranchRule(name="name_value"), + branch_rule_id="branch_rule_id_value", + ) -def test_create_instance_rest_required_fields( - request_type=secure_source_manager.CreateInstanceRequest, -): - transport_class = transports.SecureSourceManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["instance_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - assert "instanceId" not in jsonified_request - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_instance._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "instanceId" in jsonified_request - assert jsonified_request["instanceId"] == request_init["instance_id"] - - jsonified_request["parent"] = "parent_value" - jsonified_request["instanceId"] = "instance_id_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_instance._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "instance_id", - "request_id", - ) - ) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - assert "instanceId" in jsonified_request - assert jsonified_request["instanceId"] == "instance_id_value" - +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListBranchRulesRequest, + dict, + ], +) +def test_list_branch_rules(request_type, transport: str = "grpc"): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport=transport, ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_instance(request) - expected_params = [ - ( - "instanceId", - "", - ), - ("$alt", "json;enum-encoding=int"), - ] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListBranchRulesResponse( + next_page_token="next_page_token_value", + ) + response = client.list_branch_rules(request) -def test_create_instance_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ListBranchRulesRequest() + assert args[0] == request - unset_fields = transport.create_instance._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "instanceId", - "requestId", - ) - ) - & set( - ( - "parent", - "instanceId", - "instance", - ) - ) - ) + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBranchRulesPager) + assert response.next_page_token == "next_page_token_value" -def test_create_instance_rest_flattened(): +def test_list_branch_rules_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - instance=secure_source_manager.Instance(name="name_value"), - instance_id="instance_id_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_instance(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/instances" % client.transport._host, - args[1], - ) - - -def test_create_instance_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.ListBranchRulesRequest( + parent="parent_value", + page_token="page_token_value", ) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_instance( - secure_source_manager.CreateInstanceRequest(), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_branch_rules(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.ListBranchRulesRequest( parent="parent_value", - instance=secure_source_manager.Instance(name="name_value"), - instance_id="instance_id_value", + page_token="page_token_value", ) -def test_delete_instance_rest_use_cached_wrapped_rpc(): +def test_list_branch_rules_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + transport="grpc", ) # Should wrap all calls on client creation @@ -8062,3565 +8093,33001 @@ def test_delete_instance_rest_use_cached_wrapped_rpc(): wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.delete_instance in client._transport._wrapped_methods + assert client._transport.list_branch_rules in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.delete_instance] = mock_rpc - + client._transport._wrapped_methods[ + client._transport.list_branch_rules + ] = mock_rpc request = {} - client.delete_instance(request) + client.list_branch_rules(request) # Establish that the underlying gRPC stub method was called. assert mock_rpc.call_count == 1 - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_instance(request) + client.list_branch_rules(request) # Establish that a new wrapper was not created for this call assert wrapper_fn.call_count == 0 assert mock_rpc.call_count == 2 -def test_delete_instance_rest_required_fields( - request_type=secure_source_manager.DeleteInstanceRequest, +@pytest.mark.asyncio +async def test_list_branch_rules_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", ): - transport_class = transports.SecureSourceManagerRestTransport + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # verify fields with default values are dropped + # Ensure method has been cached + assert ( + client._client._transport.list_branch_rules + in client._client._transport._wrapped_methods + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_instance._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_branch_rules + ] = mock_rpc - # verify required fields with default values are now present + request = {} + await client.list_branch_rules(request) - jsonified_request["name"] = "name_value" + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_instance._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("request_id",)) - jsonified_request.update(unset_fields) + await client.list_branch_rules(request) - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + +@pytest.mark.asyncio +async def test_list_branch_rules_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.ListBranchRulesRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "delete", - "query_params": pb_request, - } - transcode.return_value = transcode_result + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListBranchRulesResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_branch_rules(request) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ListBranchRulesRequest() + assert args[0] == request - response = client.delete_instance(request) + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBranchRulesAsyncPager) + assert response.next_page_token == "next_page_token_value" - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params +@pytest.mark.asyncio +async def test_list_branch_rules_async_from_dict(): + await test_list_branch_rules_async(request_type=dict) -def test_delete_instance_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials + +def test_list_branch_rules_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), ) - unset_fields = transport.delete_instance._get_unset_required_fields({}) - assert set(unset_fields) == (set(("requestId",)) & set(("name",))) + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ListBranchRulesRequest() + request.parent = "parent_value" -def test_delete_instance_rest_flattened(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), "__call__" + ) as call: + call.return_value = secure_source_manager.ListBranchRulesResponse() + client.list_branch_rules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_branch_rules_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ListBranchRulesRequest() - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/instances/sample3" - } + request.parent = "parent_value" - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListBranchRulesResponse() ) - mock_args.update(sample_request) + await client.list_branch_rules(request) - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request - client.delete_instance(**mock_args) + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_branch_rules_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListBranchRulesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_branch_rules( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/instances/*}" % client.transport._host, - args[1], - ) + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -def test_delete_instance_rest_flattened_error(transport: str = "rest"): +def test_list_branch_rules_flattened_error(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.delete_instance( - secure_source_manager.DeleteInstanceRequest(), - name="name_value", + client.list_branch_rules( + secure_source_manager.ListBranchRulesRequest(), + parent="parent_value", ) -def test_list_repositories_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() +@pytest.mark.asyncio +async def test_list_branch_rules_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) - # Ensure method has been cached - assert client._transport.list_repositories in client._transport._wrapped_methods + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListBranchRulesResponse() - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListBranchRulesResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_branch_rules( + parent="parent_value", ) - client._transport._wrapped_methods[ - client._transport.list_repositories - ] = mock_rpc - - request = {} - client.list_repositories(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_repositories(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_repositories_rest_required_fields( - request_type=secure_source_manager.ListRepositoriesRequest, -): - transport_class = transports.SecureSourceManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_repositories._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = "parent_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_repositories._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "filter", - "instance", - "page_size", - "page_token", - ) - ) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = secure_source_manager.ListRepositoriesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = secure_source_manager.ListRepositoriesResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_repositories(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_list_repositories_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.list_repositories._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "filter", - "instance", - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) - - -def test_list_repositories_rest_flattened(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = secure_source_manager.ListRepositoriesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = secure_source_manager.ListRepositoriesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_repositories(**mock_args) # Establish that the underlying call was made with the expected # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/repositories" - % client.transport._host, - args[1], - ) + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val -def test_list_repositories_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, +@pytest.mark.asyncio +async def test_list_branch_rules_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_repositories( - secure_source_manager.ListRepositoriesRequest(), + await client.list_branch_rules( + secure_source_manager.ListBranchRulesRequest(), parent="parent_value", ) -def test_list_repositories_rest_pager(transport: str = "rest"): +def test_list_branch_rules_pager(transport_name: str = "grpc"): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport=transport_name, ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - secure_source_manager.ListRepositoriesResponse( - repositories=[ - secure_source_manager.Repository(), - secure_source_manager.Repository(), - secure_source_manager.Repository(), + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), ], next_page_token="abc", ), - secure_source_manager.ListRepositoriesResponse( - repositories=[], + secure_source_manager.ListBranchRulesResponse( + branch_rules=[], next_page_token="def", ), - secure_source_manager.ListRepositoriesResponse( - repositories=[ - secure_source_manager.Repository(), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), ], next_page_token="ghi", ), - secure_source_manager.ListRepositoriesResponse( - repositories=[ - secure_source_manager.Repository(), - secure_source_manager.Repository(), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), ], ), + RuntimeError, ) - # Two responses for two calls - response = response + response - # Wrap the values into proper Response objs - response = tuple( - secure_source_manager.ListRepositoriesResponse.to_json(x) for x in response + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {"parent": "projects/sample1/locations/sample2"} + pager = client.list_branch_rules(request={}, retry=retry, timeout=timeout) - pager = client.list_repositories(request=sample_request) + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout results = list(pager) assert len(results) == 6 - assert all(isinstance(i, secure_source_manager.Repository) for i in results) - - pages = list(client.list_repositories(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token + assert all(isinstance(i, secure_source_manager.BranchRule) for i in results) -def test_get_repository_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) +def test_list_branch_rules_pages(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + ], + next_page_token="abc", + ), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[], + next_page_token="def", + ), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + ], + ), + RuntimeError, + ) + pages = list(client.list_branch_rules(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_branch_rules_async_pager(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + ], + next_page_token="abc", + ), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[], + next_page_token="def", + ), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_branch_rules( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, secure_source_manager.BranchRule) for i in responses) + + +@pytest.mark.asyncio +async def test_list_branch_rules_async_pages(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + ], + next_page_token="abc", + ), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[], + next_page_token="def", + ), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_branch_rules(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetBranchRuleRequest, + dict, + ], +) +def test_get_branch_rule(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.BranchRule( + name="name_value", + uid="uid_value", + etag="etag_value", + include_pattern="include_pattern_value", + disabled=True, + require_pull_request=True, + minimum_reviews_count=2280, + minimum_approvals_count=2491, + require_comments_resolved=True, + allow_stale_reviews=True, + require_linear_history=True, + ) + response = client.get_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.GetBranchRuleRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.BranchRule) + assert response.name == "name_value" + assert response.uid == "uid_value" + assert response.etag == "etag_value" + assert response.include_pattern == "include_pattern_value" + assert response.disabled is True + assert response.require_pull_request is True + assert response.minimum_reviews_count == 2280 + assert response.minimum_approvals_count == 2491 + assert response.require_comments_resolved is True + assert response.allow_stale_reviews is True + assert response.require_linear_history is True + + +def test_get_branch_rule_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.GetBranchRuleRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_branch_rule(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.GetBranchRuleRequest( + name="name_value", + ) + + +def test_get_branch_rule_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 wrapper_fn.reset_mock() # Ensure method has been cached - assert client._transport.get_repository in client._transport._wrapped_methods + assert client._transport.get_branch_rule in client._transport._wrapped_methods # Replace cached wrapped function with mock mock_rpc = mock.Mock() mock_rpc.return_value.name = ( "foo" # operation_request.operation in compute client(s) expect a string. ) - client._transport._wrapped_methods[client._transport.get_repository] = mock_rpc - + client._transport._wrapped_methods[client._transport.get_branch_rule] = mock_rpc request = {} - client.get_repository(request) + client.get_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_branch_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_branch_rule_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.get_branch_rule + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_branch_rule + ] = mock_rpc + + request = {} + await client.get_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_branch_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_branch_rule_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.GetBranchRuleRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.BranchRule( + name="name_value", + uid="uid_value", + etag="etag_value", + include_pattern="include_pattern_value", + disabled=True, + require_pull_request=True, + minimum_reviews_count=2280, + minimum_approvals_count=2491, + require_comments_resolved=True, + allow_stale_reviews=True, + require_linear_history=True, + ) + ) + response = await client.get_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.GetBranchRuleRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.BranchRule) + assert response.name == "name_value" + assert response.uid == "uid_value" + assert response.etag == "etag_value" + assert response.include_pattern == "include_pattern_value" + assert response.disabled is True + assert response.require_pull_request is True + assert response.minimum_reviews_count == 2280 + assert response.minimum_approvals_count == 2491 + assert response.require_comments_resolved is True + assert response.allow_stale_reviews is True + assert response.require_linear_history is True + + +@pytest.mark.asyncio +async def test_get_branch_rule_async_from_dict(): + await test_get_branch_rule_async(request_type=dict) + + +def test_get_branch_rule_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.GetBranchRuleRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + call.return_value = secure_source_manager.BranchRule() + client.get_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_branch_rule_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.GetBranchRuleRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.BranchRule() + ) + await client.get_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_branch_rule_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.BranchRule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_branch_rule( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_branch_rule_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_branch_rule( + secure_source_manager.GetBranchRuleRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_branch_rule_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.BranchRule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.BranchRule() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_branch_rule( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_branch_rule_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_branch_rule( + secure_source_manager.GetBranchRuleRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.UpdateBranchRuleRequest, + dict, + ], +) +def test_update_branch_rule(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.update_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.UpdateBranchRuleRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_branch_rule_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.UpdateBranchRuleRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_branch_rule), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.update_branch_rule(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.UpdateBranchRuleRequest() + + +def test_update_branch_rule_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_branch_rule in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_branch_rule + ] = mock_rpc + request = {} + client.update_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_branch_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_branch_rule_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.update_branch_rule + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_branch_rule + ] = mock_rpc + + request = {} + await client.update_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.update_branch_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_branch_rule_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.UpdateBranchRuleRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.update_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.UpdateBranchRuleRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_branch_rule_async_from_dict(): + await test_update_branch_rule_async(request_type=dict) + + +def test_update_branch_rule_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.UpdateBranchRuleRequest() + + request.branch_rule.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_branch_rule), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "branch_rule.name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_branch_rule_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.UpdateBranchRuleRequest() + + request.branch_rule.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_branch_rule), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.update_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "branch_rule.name=name_value", + ) in kw["metadata"] + + +def test_update_branch_rule_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_branch_rule( + branch_rule=secure_source_manager.BranchRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].branch_rule + mock_val = secure_source_manager.BranchRule(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +def test_update_branch_rule_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_branch_rule( + secure_source_manager.UpdateBranchRuleRequest(), + branch_rule=secure_source_manager.BranchRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_branch_rule_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_branch_rule( + branch_rule=secure_source_manager.BranchRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].branch_rule + mock_val = secure_source_manager.BranchRule(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_branch_rule_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_branch_rule( + secure_source_manager.UpdateBranchRuleRequest(), + branch_rule=secure_source_manager.BranchRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.DeleteBranchRuleRequest, + dict, + ], +) +def test_delete_branch_rule(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.delete_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.DeleteBranchRuleRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_branch_rule_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.DeleteBranchRuleRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_branch_rule), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.delete_branch_rule(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.DeleteBranchRuleRequest( + name="name_value", + ) + + +def test_delete_branch_rule_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_branch_rule in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_branch_rule + ] = mock_rpc + request = {} + client.delete_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_branch_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_branch_rule_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.delete_branch_rule + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.delete_branch_rule + ] = mock_rpc + + request = {} + await client.delete_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.delete_branch_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_branch_rule_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.DeleteBranchRuleRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.delete_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.DeleteBranchRuleRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_branch_rule_async_from_dict(): + await test_delete_branch_rule_async(request_type=dict) + + +def test_delete_branch_rule_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.DeleteBranchRuleRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_branch_rule), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_branch_rule_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.DeleteBranchRuleRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_branch_rule), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.delete_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_branch_rule_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_branch_rule( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_delete_branch_rule_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_branch_rule( + secure_source_manager.DeleteBranchRuleRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_branch_rule_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_branch_rule( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_branch_rule_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_branch_rule( + secure_source_manager.DeleteBranchRuleRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CreatePullRequestRequest, + dict, + ], +) +def test_create_pull_request(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.create_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.CreatePullRequestRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_pull_request_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.CreatePullRequestRequest( + parent="parent_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_pull_request(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.CreatePullRequestRequest( + parent="parent_value", + ) + + +def test_create_pull_request_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_pull_request in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_pull_request + ] = mock_rpc + request = {} + client.create_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_pull_request_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.create_pull_request + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_pull_request + ] = mock_rpc + + request = {} + await client.create_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.create_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_pull_request_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.CreatePullRequestRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.create_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.CreatePullRequestRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_pull_request_async_from_dict(): + await test_create_pull_request_async(request_type=dict) + + +def test_create_pull_request_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.CreatePullRequestRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_pull_request_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.CreatePullRequestRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.create_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_pull_request_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_pull_request( + parent="parent_value", + pull_request=secure_source_manager.PullRequest(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].pull_request + mock_val = secure_source_manager.PullRequest(name="name_value") + assert arg == mock_val + + +def test_create_pull_request_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_pull_request( + secure_source_manager.CreatePullRequestRequest(), + parent="parent_value", + pull_request=secure_source_manager.PullRequest(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_pull_request_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_pull_request( + parent="parent_value", + pull_request=secure_source_manager.PullRequest(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].pull_request + mock_val = secure_source_manager.PullRequest(name="name_value") + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_pull_request_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_pull_request( + secure_source_manager.CreatePullRequestRequest(), + parent="parent_value", + pull_request=secure_source_manager.PullRequest(name="name_value"), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetPullRequestRequest, + dict, + ], +) +def test_get_pull_request(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_pull_request), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.PullRequest( + name="name_value", + title="title_value", + body="body_value", + state=secure_source_manager.PullRequest.State.OPEN, + ) + response = client.get_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.GetPullRequestRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.PullRequest) + assert response.name == "name_value" + assert response.title == "title_value" + assert response.body == "body_value" + assert response.state == secure_source_manager.PullRequest.State.OPEN + + +def test_get_pull_request_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.GetPullRequestRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_pull_request), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_pull_request(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.GetPullRequestRequest( + name="name_value", + ) + + +def test_get_pull_request_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_pull_request in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_pull_request + ] = mock_rpc + request = {} + client.get_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_pull_request_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.get_pull_request + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_pull_request + ] = mock_rpc + + request = {} + await client.get_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_pull_request_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.GetPullRequestRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_pull_request), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.PullRequest( + name="name_value", + title="title_value", + body="body_value", + state=secure_source_manager.PullRequest.State.OPEN, + ) + ) + response = await client.get_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.GetPullRequestRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.PullRequest) + assert response.name == "name_value" + assert response.title == "title_value" + assert response.body == "body_value" + assert response.state == secure_source_manager.PullRequest.State.OPEN + + +@pytest.mark.asyncio +async def test_get_pull_request_async_from_dict(): + await test_get_pull_request_async(request_type=dict) + + +def test_get_pull_request_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.GetPullRequestRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_pull_request), "__call__") as call: + call.return_value = secure_source_manager.PullRequest() + client.get_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_pull_request_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.GetPullRequestRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_pull_request), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.PullRequest() + ) + await client.get_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_pull_request_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_pull_request), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.PullRequest() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_pull_request( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_pull_request_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_pull_request( + secure_source_manager.GetPullRequestRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_pull_request_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_pull_request), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.PullRequest() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.PullRequest() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_pull_request( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_pull_request_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_pull_request( + secure_source_manager.GetPullRequestRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListPullRequestsRequest, + dict, + ], +) +def test_list_pull_requests(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListPullRequestsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_pull_requests(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ListPullRequestsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPullRequestsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_pull_requests_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.ListPullRequestsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_pull_requests(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.ListPullRequestsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + +def test_list_pull_requests_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_pull_requests in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_pull_requests + ] = mock_rpc + request = {} + client.list_pull_requests(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_pull_requests(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_pull_requests_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.list_pull_requests + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_pull_requests + ] = mock_rpc + + request = {} + await client.list_pull_requests(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_pull_requests(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_pull_requests_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.ListPullRequestsRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListPullRequestsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_pull_requests(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ListPullRequestsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPullRequestsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_pull_requests_async_from_dict(): + await test_list_pull_requests_async(request_type=dict) + + +def test_list_pull_requests_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ListPullRequestsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), "__call__" + ) as call: + call.return_value = secure_source_manager.ListPullRequestsResponse() + client.list_pull_requests(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_pull_requests_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ListPullRequestsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListPullRequestsResponse() + ) + await client.list_pull_requests(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_pull_requests_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListPullRequestsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_pull_requests( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_pull_requests_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_pull_requests( + secure_source_manager.ListPullRequestsRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_pull_requests_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListPullRequestsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListPullRequestsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_pull_requests( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_pull_requests_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_pull_requests( + secure_source_manager.ListPullRequestsRequest(), + parent="parent_value", + ) + + +def test_list_pull_requests_pager(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_pull_requests(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.PullRequest) for i in results) + + +def test_list_pull_requests_pages(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + ], + ), + RuntimeError, + ) + pages = list(client.list_pull_requests(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_pull_requests_async_pager(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_pull_requests( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, secure_source_manager.PullRequest) for i in responses) + + +@pytest.mark.asyncio +async def test_list_pull_requests_async_pages(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_pull_requests(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.UpdatePullRequestRequest, + dict, + ], +) +def test_update_pull_request(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.update_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.UpdatePullRequestRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_pull_request_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.UpdatePullRequestRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.update_pull_request(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.UpdatePullRequestRequest() + + +def test_update_pull_request_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_pull_request in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_pull_request + ] = mock_rpc + request = {} + client.update_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_pull_request_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.update_pull_request + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_pull_request + ] = mock_rpc + + request = {} + await client.update_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.update_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_pull_request_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.UpdatePullRequestRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.update_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.UpdatePullRequestRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_pull_request_async_from_dict(): + await test_update_pull_request_async(request_type=dict) + + +def test_update_pull_request_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.UpdatePullRequestRequest() + + request.pull_request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "pull_request.name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_pull_request_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.UpdatePullRequestRequest() + + request.pull_request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.update_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "pull_request.name=name_value", + ) in kw["metadata"] + + +def test_update_pull_request_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_pull_request( + pull_request=secure_source_manager.PullRequest(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].pull_request + mock_val = secure_source_manager.PullRequest(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +def test_update_pull_request_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_pull_request( + secure_source_manager.UpdatePullRequestRequest(), + pull_request=secure_source_manager.PullRequest(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_pull_request_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_pull_request( + pull_request=secure_source_manager.PullRequest(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].pull_request + mock_val = secure_source_manager.PullRequest(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_pull_request_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_pull_request( + secure_source_manager.UpdatePullRequestRequest(), + pull_request=secure_source_manager.PullRequest(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.MergePullRequestRequest, + dict, + ], +) +def test_merge_pull_request(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.merge_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.merge_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.MergePullRequestRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_merge_pull_request_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.MergePullRequestRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.merge_pull_request), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.merge_pull_request(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.MergePullRequestRequest( + name="name_value", + ) + + +def test_merge_pull_request_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.merge_pull_request in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.merge_pull_request + ] = mock_rpc + request = {} + client.merge_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.merge_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_merge_pull_request_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.merge_pull_request + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.merge_pull_request + ] = mock_rpc + + request = {} + await client.merge_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.merge_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_merge_pull_request_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.MergePullRequestRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.merge_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.merge_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.MergePullRequestRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_merge_pull_request_async_from_dict(): + await test_merge_pull_request_async(request_type=dict) + + +def test_merge_pull_request_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.MergePullRequestRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.merge_pull_request), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.merge_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_merge_pull_request_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.MergePullRequestRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.merge_pull_request), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.merge_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_merge_pull_request_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.merge_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.merge_pull_request( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_merge_pull_request_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.merge_pull_request( + secure_source_manager.MergePullRequestRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_merge_pull_request_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.merge_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.merge_pull_request( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_merge_pull_request_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.merge_pull_request( + secure_source_manager.MergePullRequestRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.OpenPullRequestRequest, + dict, + ], +) +def test_open_pull_request(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.open_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.open_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.OpenPullRequestRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_open_pull_request_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.OpenPullRequestRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.open_pull_request), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.open_pull_request(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.OpenPullRequestRequest( + name="name_value", + ) + + +def test_open_pull_request_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.open_pull_request in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.open_pull_request + ] = mock_rpc + request = {} + client.open_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.open_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_open_pull_request_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.open_pull_request + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.open_pull_request + ] = mock_rpc + + request = {} + await client.open_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.open_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_open_pull_request_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.OpenPullRequestRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.open_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.open_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.OpenPullRequestRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_open_pull_request_async_from_dict(): + await test_open_pull_request_async(request_type=dict) + + +def test_open_pull_request_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.OpenPullRequestRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.open_pull_request), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.open_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_open_pull_request_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.OpenPullRequestRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.open_pull_request), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.open_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_open_pull_request_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.open_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.open_pull_request( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_open_pull_request_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.open_pull_request( + secure_source_manager.OpenPullRequestRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_open_pull_request_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.open_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.open_pull_request( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_open_pull_request_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.open_pull_request( + secure_source_manager.OpenPullRequestRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ClosePullRequestRequest, + dict, + ], +) +def test_close_pull_request(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.close_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.close_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ClosePullRequestRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_close_pull_request_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.ClosePullRequestRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.close_pull_request), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.close_pull_request(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.ClosePullRequestRequest( + name="name_value", + ) + + +def test_close_pull_request_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.close_pull_request in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.close_pull_request + ] = mock_rpc + request = {} + client.close_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.close_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_close_pull_request_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.close_pull_request + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.close_pull_request + ] = mock_rpc + + request = {} + await client.close_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.close_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_close_pull_request_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.ClosePullRequestRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.close_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.close_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ClosePullRequestRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_close_pull_request_async_from_dict(): + await test_close_pull_request_async(request_type=dict) + + +def test_close_pull_request_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ClosePullRequestRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.close_pull_request), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.close_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_close_pull_request_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ClosePullRequestRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.close_pull_request), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.close_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_close_pull_request_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.close_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.close_pull_request( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_close_pull_request_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.close_pull_request( + secure_source_manager.ClosePullRequestRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_close_pull_request_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.close_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.close_pull_request( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_close_pull_request_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.close_pull_request( + secure_source_manager.ClosePullRequestRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListPullRequestFileDiffsRequest, + dict, + ], +) +def test_list_pull_request_file_diffs(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListPullRequestFileDiffsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_pull_request_file_diffs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ListPullRequestFileDiffsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPullRequestFileDiffsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_pull_request_file_diffs_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.ListPullRequestFileDiffsRequest( + name="name_value", + page_token="page_token_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_pull_request_file_diffs(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.ListPullRequestFileDiffsRequest( + name="name_value", + page_token="page_token_value", + ) + + +def test_list_pull_request_file_diffs_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_pull_request_file_diffs + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_pull_request_file_diffs + ] = mock_rpc + request = {} + client.list_pull_request_file_diffs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_pull_request_file_diffs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_pull_request_file_diffs_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.list_pull_request_file_diffs + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_pull_request_file_diffs + ] = mock_rpc + + request = {} + await client.list_pull_request_file_diffs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_pull_request_file_diffs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_pull_request_file_diffs_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.ListPullRequestFileDiffsRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListPullRequestFileDiffsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_pull_request_file_diffs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ListPullRequestFileDiffsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPullRequestFileDiffsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_pull_request_file_diffs_async_from_dict(): + await test_list_pull_request_file_diffs_async(request_type=dict) + + +def test_list_pull_request_file_diffs_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ListPullRequestFileDiffsRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), "__call__" + ) as call: + call.return_value = secure_source_manager.ListPullRequestFileDiffsResponse() + client.list_pull_request_file_diffs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_pull_request_file_diffs_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ListPullRequestFileDiffsRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListPullRequestFileDiffsResponse() + ) + await client.list_pull_request_file_diffs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_list_pull_request_file_diffs_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListPullRequestFileDiffsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_pull_request_file_diffs( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_list_pull_request_file_diffs_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_pull_request_file_diffs( + secure_source_manager.ListPullRequestFileDiffsRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_list_pull_request_file_diffs_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListPullRequestFileDiffsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListPullRequestFileDiffsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_pull_request_file_diffs( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_pull_request_file_diffs_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_pull_request_file_diffs( + secure_source_manager.ListPullRequestFileDiffsRequest(), + name="name_value", + ) + + +def test_list_pull_request_file_diffs_pager(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", ""),)), + ) + pager = client.list_pull_request_file_diffs( + request={}, retry=retry, timeout=timeout + ) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.FileDiff) for i in results) + + +def test_list_pull_request_file_diffs_pages(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + ], + ), + RuntimeError, + ) + pages = list(client.list_pull_request_file_diffs(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_pull_request_file_diffs_async_pager(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_pull_request_file_diffs( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, secure_source_manager.FileDiff) for i in responses) + + +@pytest.mark.asyncio +async def test_list_pull_request_file_diffs_async_pages(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_pull_request_file_diffs(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.FetchTreeRequest, + dict, + ], +) +def test_fetch_tree(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.fetch_tree), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.FetchTreeResponse( + next_page_token="next_page_token_value", + ) + response = client.fetch_tree(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.FetchTreeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.FetchTreePager) + assert response.next_page_token == "next_page_token_value" + + +def test_fetch_tree_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.FetchTreeRequest( + repository="repository_value", + ref="ref_value", + page_token="page_token_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.fetch_tree), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.fetch_tree(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.FetchTreeRequest( + repository="repository_value", + ref="ref_value", + page_token="page_token_value", + ) + + +def test_fetch_tree_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.fetch_tree in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.fetch_tree] = mock_rpc + request = {} + client.fetch_tree(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.fetch_tree(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_fetch_tree_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.fetch_tree + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.fetch_tree + ] = mock_rpc + + request = {} + await client.fetch_tree(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.fetch_tree(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_fetch_tree_async( + transport: str = "grpc_asyncio", request_type=secure_source_manager.FetchTreeRequest +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.fetch_tree), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.FetchTreeResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.fetch_tree(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.FetchTreeRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.FetchTreeAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_fetch_tree_async_from_dict(): + await test_fetch_tree_async(request_type=dict) + + +def test_fetch_tree_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.FetchTreeRequest() + + request.repository = "repository_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.fetch_tree), "__call__") as call: + call.return_value = secure_source_manager.FetchTreeResponse() + client.fetch_tree(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "repository=repository_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_fetch_tree_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.FetchTreeRequest() + + request.repository = "repository_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.fetch_tree), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.FetchTreeResponse() + ) + await client.fetch_tree(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "repository=repository_value", + ) in kw["metadata"] + + +def test_fetch_tree_pager(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.fetch_tree), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + ], + next_page_token="abc", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[], + next_page_token="def", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + ], + next_page_token="ghi", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("repository", ""),)), + ) + pager = client.fetch_tree(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.TreeEntry) for i in results) + + +def test_fetch_tree_pages(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.fetch_tree), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + ], + next_page_token="abc", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[], + next_page_token="def", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + ], + next_page_token="ghi", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + ], + ), + RuntimeError, + ) + pages = list(client.fetch_tree(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_fetch_tree_async_pager(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_tree), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + ], + next_page_token="abc", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[], + next_page_token="def", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + ], + next_page_token="ghi", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + ], + ), + RuntimeError, + ) + async_pager = await client.fetch_tree( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, secure_source_manager.TreeEntry) for i in responses) + + +@pytest.mark.asyncio +async def test_fetch_tree_async_pages(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.fetch_tree), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + ], + next_page_token="abc", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[], + next_page_token="def", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + ], + next_page_token="ghi", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.fetch_tree(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.FetchBlobRequest, + dict, + ], +) +def test_fetch_blob(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.fetch_blob), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.FetchBlobResponse( + sha="sha_value", + content="content_value", + ) + response = client.fetch_blob(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.FetchBlobRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.FetchBlobResponse) + assert response.sha == "sha_value" + assert response.content == "content_value" + + +def test_fetch_blob_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.FetchBlobRequest( + repository="repository_value", + sha="sha_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.fetch_blob), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.fetch_blob(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.FetchBlobRequest( + repository="repository_value", + sha="sha_value", + ) + + +def test_fetch_blob_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.fetch_blob in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.fetch_blob] = mock_rpc + request = {} + client.fetch_blob(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.fetch_blob(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_fetch_blob_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.fetch_blob + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.fetch_blob + ] = mock_rpc + + request = {} + await client.fetch_blob(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.fetch_blob(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_fetch_blob_async( + transport: str = "grpc_asyncio", request_type=secure_source_manager.FetchBlobRequest +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.fetch_blob), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.FetchBlobResponse( + sha="sha_value", + content="content_value", + ) + ) + response = await client.fetch_blob(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.FetchBlobRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.FetchBlobResponse) + assert response.sha == "sha_value" + assert response.content == "content_value" + + +@pytest.mark.asyncio +async def test_fetch_blob_async_from_dict(): + await test_fetch_blob_async(request_type=dict) + + +def test_fetch_blob_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.FetchBlobRequest() + + request.repository = "repository_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.fetch_blob), "__call__") as call: + call.return_value = secure_source_manager.FetchBlobResponse() + client.fetch_blob(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "repository=repository_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_fetch_blob_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.FetchBlobRequest() + + request.repository = "repository_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.fetch_blob), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.FetchBlobResponse() + ) + await client.fetch_blob(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "repository=repository_value", + ) in kw["metadata"] + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CreateIssueRequest, + dict, + ], +) +def test_create_issue(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.create_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.CreateIssueRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_issue_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.CreateIssueRequest( + parent="parent_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_issue), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_issue(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.CreateIssueRequest( + parent="parent_value", + ) + + +def test_create_issue_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.create_issue] = mock_rpc + request = {} + client.create_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_issue_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.create_issue + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_issue + ] = mock_rpc + + request = {} + await client.create_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.create_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_issue_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.CreateIssueRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.create_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.CreateIssueRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_issue_async_from_dict(): + await test_create_issue_async(request_type=dict) + + +def test_create_issue_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.CreateIssueRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_issue), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_issue_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.CreateIssueRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_issue), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.create_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_issue_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_issue( + parent="parent_value", + issue=secure_source_manager.Issue(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].issue + mock_val = secure_source_manager.Issue(name="name_value") + assert arg == mock_val + + +def test_create_issue_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_issue( + secure_source_manager.CreateIssueRequest(), + parent="parent_value", + issue=secure_source_manager.Issue(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_issue_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_issue( + parent="parent_value", + issue=secure_source_manager.Issue(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].issue + mock_val = secure_source_manager.Issue(name="name_value") + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_issue_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_issue( + secure_source_manager.CreateIssueRequest(), + parent="parent_value", + issue=secure_source_manager.Issue(name="name_value"), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetIssueRequest, + dict, + ], +) +def test_get_issue(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.Issue( + name="name_value", + title="title_value", + body="body_value", + state=secure_source_manager.Issue.State.OPEN, + etag="etag_value", + ) + response = client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.GetIssueRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.Issue) + assert response.name == "name_value" + assert response.title == "title_value" + assert response.body == "body_value" + assert response.state == secure_source_manager.Issue.State.OPEN + assert response.etag == "etag_value" + + +def test_get_issue_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.GetIssueRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_issue(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.GetIssueRequest( + name="name_value", + ) + + +def test_get_issue_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_issue] = mock_rpc + request = {} + client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_issue_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.get_issue + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_issue + ] = mock_rpc + + request = {} + await client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_issue_async( + transport: str = "grpc_asyncio", request_type=secure_source_manager.GetIssueRequest +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.Issue( + name="name_value", + title="title_value", + body="body_value", + state=secure_source_manager.Issue.State.OPEN, + etag="etag_value", + ) + ) + response = await client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.GetIssueRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.Issue) + assert response.name == "name_value" + assert response.title == "title_value" + assert response.body == "body_value" + assert response.state == secure_source_manager.Issue.State.OPEN + assert response.etag == "etag_value" + + +@pytest.mark.asyncio +async def test_get_issue_async_from_dict(): + await test_get_issue_async(request_type=dict) + + +def test_get_issue_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.GetIssueRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + call.return_value = secure_source_manager.Issue() + client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_issue_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.GetIssueRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.Issue() + ) + await client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_issue_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.Issue() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_issue( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_issue_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_issue( + secure_source_manager.GetIssueRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_issue_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.Issue() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.Issue() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_issue( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_issue_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_issue( + secure_source_manager.GetIssueRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListIssuesRequest, + dict, + ], +) +def test_list_issues(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListIssuesResponse( + next_page_token="next_page_token_value", + ) + response = client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ListIssuesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListIssuesPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_issues_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.ListIssuesRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_issues(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.ListIssuesRequest( + parent="parent_value", + page_token="page_token_value", + filter="filter_value", + ) + + +def test_list_issues_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_issues in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_issues] = mock_rpc + request = {} + client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_issues(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_issues_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.list_issues + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_issues + ] = mock_rpc + + request = {} + await client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_issues(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_issues_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.ListIssuesRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListIssuesResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ListIssuesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListIssuesAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_issues_async_from_dict(): + await test_list_issues_async(request_type=dict) + + +def test_list_issues_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ListIssuesRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + call.return_value = secure_source_manager.ListIssuesResponse() + client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_issues_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ListIssuesRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListIssuesResponse() + ) + await client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_issues_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListIssuesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_issues( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_issues_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issues( + secure_source_manager.ListIssuesRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_issues_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListIssuesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListIssuesResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_issues( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_issues_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_issues( + secure_source_manager.ListIssuesRequest(), + parent="parent_value", + ) + + +def test_list_issues_pager(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + secure_source_manager.Issue(), + secure_source_manager.Issue(), + ], + next_page_token="abc", + ), + secure_source_manager.ListIssuesResponse( + issues=[], + next_page_token="def", + ), + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + secure_source_manager.Issue(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_issues(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.Issue) for i in results) + + +def test_list_issues_pages(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + secure_source_manager.Issue(), + secure_source_manager.Issue(), + ], + next_page_token="abc", + ), + secure_source_manager.ListIssuesResponse( + issues=[], + next_page_token="def", + ), + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + secure_source_manager.Issue(), + ], + ), + RuntimeError, + ) + pages = list(client.list_issues(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_issues_async_pager(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + secure_source_manager.Issue(), + secure_source_manager.Issue(), + ], + next_page_token="abc", + ), + secure_source_manager.ListIssuesResponse( + issues=[], + next_page_token="def", + ), + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + secure_source_manager.Issue(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_issues( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, secure_source_manager.Issue) for i in responses) + + +@pytest.mark.asyncio +async def test_list_issues_async_pages(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issues), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + secure_source_manager.Issue(), + secure_source_manager.Issue(), + ], + next_page_token="abc", + ), + secure_source_manager.ListIssuesResponse( + issues=[], + next_page_token="def", + ), + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + secure_source_manager.Issue(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_issues(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.UpdateIssueRequest, + dict, + ], +) +def test_update_issue(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.UpdateIssueRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_issue_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.UpdateIssueRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.update_issue(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.UpdateIssueRequest() + + +def test_update_issue_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_issue] = mock_rpc + request = {} + client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_issue_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.update_issue + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_issue + ] = mock_rpc + + request = {} + await client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.update_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_issue_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.UpdateIssueRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.UpdateIssueRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_issue_async_from_dict(): + await test_update_issue_async(request_type=dict) + + +def test_update_issue_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.UpdateIssueRequest() + + request.issue.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "issue.name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_issue_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.UpdateIssueRequest() + + request.issue.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "issue.name=name_value", + ) in kw["metadata"] + + +def test_update_issue_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_issue( + issue=secure_source_manager.Issue(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].issue + mock_val = secure_source_manager.Issue(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +def test_update_issue_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue( + secure_source_manager.UpdateIssueRequest(), + issue=secure_source_manager.Issue(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_issue_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_issue( + issue=secure_source_manager.Issue(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].issue + mock_val = secure_source_manager.Issue(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_issue_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_issue( + secure_source_manager.UpdateIssueRequest(), + issue=secure_source_manager.Issue(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.DeleteIssueRequest, + dict, + ], +) +def test_delete_issue(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.delete_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.DeleteIssueRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_issue_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.DeleteIssueRequest( + name="name_value", + etag="etag_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.delete_issue(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.DeleteIssueRequest( + name="name_value", + etag="etag_value", + ) + + +def test_delete_issue_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_issue] = mock_rpc + request = {} + client.delete_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_issue_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.delete_issue + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.delete_issue + ] = mock_rpc + + request = {} + await client.delete_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.delete_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_issue_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.DeleteIssueRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.delete_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.DeleteIssueRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_issue_async_from_dict(): + await test_delete_issue_async(request_type=dict) + + +def test_delete_issue_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.DeleteIssueRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_issue_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.DeleteIssueRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.delete_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_issue_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_issue( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_delete_issue_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_issue( + secure_source_manager.DeleteIssueRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_issue_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_issue( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_issue_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_issue( + secure_source_manager.DeleteIssueRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.OpenIssueRequest, + dict, + ], +) +def test_open_issue(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.open_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.open_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.OpenIssueRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_open_issue_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.OpenIssueRequest( + name="name_value", + etag="etag_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.open_issue), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.open_issue(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.OpenIssueRequest( + name="name_value", + etag="etag_value", + ) + + +def test_open_issue_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.open_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.open_issue] = mock_rpc + request = {} + client.open_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.open_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_open_issue_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.open_issue + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.open_issue + ] = mock_rpc + + request = {} + await client.open_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.open_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_open_issue_async( + transport: str = "grpc_asyncio", request_type=secure_source_manager.OpenIssueRequest +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.open_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.open_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.OpenIssueRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_open_issue_async_from_dict(): + await test_open_issue_async(request_type=dict) + + +def test_open_issue_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.OpenIssueRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.open_issue), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.open_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_open_issue_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.OpenIssueRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.open_issue), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.open_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_open_issue_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.open_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.open_issue( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_open_issue_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.open_issue( + secure_source_manager.OpenIssueRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_open_issue_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.open_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.open_issue( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_open_issue_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.open_issue( + secure_source_manager.OpenIssueRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CloseIssueRequest, + dict, + ], +) +def test_close_issue(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.close_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.close_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.CloseIssueRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_close_issue_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.CloseIssueRequest( + name="name_value", + etag="etag_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.close_issue), "__call__") as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.close_issue(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.CloseIssueRequest( + name="name_value", + etag="etag_value", + ) + + +def test_close_issue_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.close_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.close_issue] = mock_rpc + request = {} + client.close_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.close_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_close_issue_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.close_issue + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.close_issue + ] = mock_rpc + + request = {} + await client.close_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.close_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_close_issue_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.CloseIssueRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.close_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.close_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.CloseIssueRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_close_issue_async_from_dict(): + await test_close_issue_async(request_type=dict) + + +def test_close_issue_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.CloseIssueRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.close_issue), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.close_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_close_issue_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.CloseIssueRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.close_issue), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.close_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_close_issue_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.close_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.close_issue( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_close_issue_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.close_issue( + secure_source_manager.CloseIssueRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_close_issue_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.close_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.close_issue( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_close_issue_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.close_issue( + secure_source_manager.CloseIssueRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetPullRequestCommentRequest, + dict, + ], +) +def test_get_pull_request_comment(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.PullRequestComment( + name="name_value", + ) + response = client.get_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.GetPullRequestCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.PullRequestComment) + assert response.name == "name_value" + + +def test_get_pull_request_comment_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.GetPullRequestCommentRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_pull_request_comment), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_pull_request_comment(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.GetPullRequestCommentRequest( + name="name_value", + ) + + +def test_get_pull_request_comment_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_pull_request_comment + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_pull_request_comment + ] = mock_rpc + request = {} + client.get_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_pull_request_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_pull_request_comment_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.get_pull_request_comment + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_pull_request_comment + ] = mock_rpc + + request = {} + await client.get_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_pull_request_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_pull_request_comment_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.GetPullRequestCommentRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.PullRequestComment( + name="name_value", + ) + ) + response = await client.get_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.GetPullRequestCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.PullRequestComment) + assert response.name == "name_value" + + +@pytest.mark.asyncio +async def test_get_pull_request_comment_async_from_dict(): + await test_get_pull_request_comment_async(request_type=dict) + + +def test_get_pull_request_comment_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.GetPullRequestCommentRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_pull_request_comment), "__call__" + ) as call: + call.return_value = secure_source_manager.PullRequestComment() + client.get_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_pull_request_comment_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.GetPullRequestCommentRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_pull_request_comment), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.PullRequestComment() + ) + await client.get_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_pull_request_comment_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.PullRequestComment() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_pull_request_comment( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_pull_request_comment_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_pull_request_comment( + secure_source_manager.GetPullRequestCommentRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_pull_request_comment_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.PullRequestComment() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.PullRequestComment() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_pull_request_comment( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_pull_request_comment_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_pull_request_comment( + secure_source_manager.GetPullRequestCommentRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListPullRequestCommentsRequest, + dict, + ], +) +def test_list_pull_request_comments(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListPullRequestCommentsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ListPullRequestCommentsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPullRequestCommentsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_pull_request_comments_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.ListPullRequestCommentsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_pull_request_comments(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.ListPullRequestCommentsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + +def test_list_pull_request_comments_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_pull_request_comments + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_pull_request_comments + ] = mock_rpc + request = {} + client.list_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_pull_request_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_pull_request_comments_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.list_pull_request_comments + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_pull_request_comments + ] = mock_rpc + + request = {} + await client.list_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_pull_request_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_pull_request_comments_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.ListPullRequestCommentsRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListPullRequestCommentsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ListPullRequestCommentsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPullRequestCommentsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_pull_request_comments_async_from_dict(): + await test_list_pull_request_comments_async(request_type=dict) + + +def test_list_pull_request_comments_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ListPullRequestCommentsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), "__call__" + ) as call: + call.return_value = secure_source_manager.ListPullRequestCommentsResponse() + client.list_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_pull_request_comments_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ListPullRequestCommentsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListPullRequestCommentsResponse() + ) + await client.list_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_pull_request_comments_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListPullRequestCommentsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_pull_request_comments( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_pull_request_comments_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_pull_request_comments( + secure_source_manager.ListPullRequestCommentsRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_pull_request_comments_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListPullRequestCommentsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListPullRequestCommentsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_pull_request_comments( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_pull_request_comments_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_pull_request_comments( + secure_source_manager.ListPullRequestCommentsRequest(), + parent="parent_value", + ) + + +def test_list_pull_request_comments_pager(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_pull_request_comments( + request={}, retry=retry, timeout=timeout + ) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all( + isinstance(i, secure_source_manager.PullRequestComment) for i in results + ) + + +def test_list_pull_request_comments_pages(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + ], + ), + RuntimeError, + ) + pages = list(client.list_pull_request_comments(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_pull_request_comments_async_pager(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_pull_request_comments( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all( + isinstance(i, secure_source_manager.PullRequestComment) for i in responses + ) + + +@pytest.mark.asyncio +async def test_list_pull_request_comments_async_pages(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_pull_request_comments(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CreatePullRequestCommentRequest, + dict, + ], +) +def test_create_pull_request_comment(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.create_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.CreatePullRequestCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_pull_request_comment_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.CreatePullRequestCommentRequest( + parent="parent_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request_comment), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_pull_request_comment(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.CreatePullRequestCommentRequest( + parent="parent_value", + ) + + +def test_create_pull_request_comment_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_pull_request_comment + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_pull_request_comment + ] = mock_rpc + request = {} + client.create_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_pull_request_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_pull_request_comment_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.create_pull_request_comment + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_pull_request_comment + ] = mock_rpc + + request = {} + await client.create_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.create_pull_request_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_pull_request_comment_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.CreatePullRequestCommentRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.create_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.CreatePullRequestCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_pull_request_comment_async_from_dict(): + await test_create_pull_request_comment_async(request_type=dict) + + +def test_create_pull_request_comment_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.CreatePullRequestCommentRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request_comment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_pull_request_comment_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.CreatePullRequestCommentRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request_comment), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.create_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_pull_request_comment_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_pull_request_comment( + parent="parent_value", + pull_request_comment=secure_source_manager.PullRequestComment( + name="name_value" + ), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].pull_request_comment + mock_val = secure_source_manager.PullRequestComment(name="name_value") + assert arg == mock_val + + +def test_create_pull_request_comment_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_pull_request_comment( + secure_source_manager.CreatePullRequestCommentRequest(), + parent="parent_value", + pull_request_comment=secure_source_manager.PullRequestComment( + name="name_value" + ), + ) + + +@pytest.mark.asyncio +async def test_create_pull_request_comment_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_pull_request_comment( + parent="parent_value", + pull_request_comment=secure_source_manager.PullRequestComment( + name="name_value" + ), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].pull_request_comment + mock_val = secure_source_manager.PullRequestComment(name="name_value") + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_pull_request_comment_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_pull_request_comment( + secure_source_manager.CreatePullRequestCommentRequest(), + parent="parent_value", + pull_request_comment=secure_source_manager.PullRequestComment( + name="name_value" + ), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.UpdatePullRequestCommentRequest, + dict, + ], +) +def test_update_pull_request_comment(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.update_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.UpdatePullRequestCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_pull_request_comment_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.UpdatePullRequestCommentRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request_comment), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.update_pull_request_comment(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.UpdatePullRequestCommentRequest() + + +def test_update_pull_request_comment_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_pull_request_comment + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_pull_request_comment + ] = mock_rpc + request = {} + client.update_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_pull_request_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_pull_request_comment_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.update_pull_request_comment + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_pull_request_comment + ] = mock_rpc + + request = {} + await client.update_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.update_pull_request_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_pull_request_comment_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.UpdatePullRequestCommentRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.update_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.UpdatePullRequestCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_pull_request_comment_async_from_dict(): + await test_update_pull_request_comment_async(request_type=dict) + + +def test_update_pull_request_comment_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.UpdatePullRequestCommentRequest() + + request.pull_request_comment.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request_comment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "pull_request_comment.name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_pull_request_comment_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.UpdatePullRequestCommentRequest() + + request.pull_request_comment.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request_comment), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.update_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "pull_request_comment.name=name_value", + ) in kw["metadata"] + + +def test_update_pull_request_comment_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_pull_request_comment( + pull_request_comment=secure_source_manager.PullRequestComment( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].pull_request_comment + mock_val = secure_source_manager.PullRequestComment(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +def test_update_pull_request_comment_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_pull_request_comment( + secure_source_manager.UpdatePullRequestCommentRequest(), + pull_request_comment=secure_source_manager.PullRequestComment( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_pull_request_comment_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_pull_request_comment( + pull_request_comment=secure_source_manager.PullRequestComment( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].pull_request_comment + mock_val = secure_source_manager.PullRequestComment(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_pull_request_comment_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_pull_request_comment( + secure_source_manager.UpdatePullRequestCommentRequest(), + pull_request_comment=secure_source_manager.PullRequestComment( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.DeletePullRequestCommentRequest, + dict, + ], +) +def test_delete_pull_request_comment(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.delete_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.DeletePullRequestCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_pull_request_comment_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.DeletePullRequestCommentRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_pull_request_comment), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.delete_pull_request_comment(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.DeletePullRequestCommentRequest( + name="name_value", + ) + + +def test_delete_pull_request_comment_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_pull_request_comment + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_pull_request_comment + ] = mock_rpc + request = {} + client.delete_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_pull_request_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_pull_request_comment_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.delete_pull_request_comment + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.delete_pull_request_comment + ] = mock_rpc + + request = {} + await client.delete_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.delete_pull_request_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_pull_request_comment_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.DeletePullRequestCommentRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.delete_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.DeletePullRequestCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_pull_request_comment_async_from_dict(): + await test_delete_pull_request_comment_async(request_type=dict) + + +def test_delete_pull_request_comment_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.DeletePullRequestCommentRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_pull_request_comment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_pull_request_comment_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.DeletePullRequestCommentRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_pull_request_comment), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.delete_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_pull_request_comment_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_pull_request_comment( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_delete_pull_request_comment_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_pull_request_comment( + secure_source_manager.DeletePullRequestCommentRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_pull_request_comment_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_pull_request_comment( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_pull_request_comment_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_pull_request_comment( + secure_source_manager.DeletePullRequestCommentRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.BatchCreatePullRequestCommentsRequest, + dict, + ], +) +def test_batch_create_pull_request_comments(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.batch_create_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.BatchCreatePullRequestCommentsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_batch_create_pull_request_comments_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.BatchCreatePullRequestCommentsRequest( + parent="parent_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_pull_request_comments), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.batch_create_pull_request_comments(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.BatchCreatePullRequestCommentsRequest( + parent="parent_value", + ) + + +def test_batch_create_pull_request_comments_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.batch_create_pull_request_comments + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.batch_create_pull_request_comments + ] = mock_rpc + request = {} + client.batch_create_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.batch_create_pull_request_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_batch_create_pull_request_comments_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.batch_create_pull_request_comments + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.batch_create_pull_request_comments + ] = mock_rpc + + request = {} + await client.batch_create_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.batch_create_pull_request_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_batch_create_pull_request_comments_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.BatchCreatePullRequestCommentsRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.batch_create_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.BatchCreatePullRequestCommentsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_batch_create_pull_request_comments_async_from_dict(): + await test_batch_create_pull_request_comments_async(request_type=dict) + + +def test_batch_create_pull_request_comments_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.BatchCreatePullRequestCommentsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_pull_request_comments), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.batch_create_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_batch_create_pull_request_comments_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.BatchCreatePullRequestCommentsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_pull_request_comments), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.batch_create_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_batch_create_pull_request_comments_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.batch_create_pull_request_comments( + parent="parent_value", + requests=[ + secure_source_manager.CreatePullRequestCommentRequest( + parent="parent_value" + ) + ], + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].requests + mock_val = [ + secure_source_manager.CreatePullRequestCommentRequest(parent="parent_value") + ] + assert arg == mock_val + + +def test_batch_create_pull_request_comments_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.batch_create_pull_request_comments( + secure_source_manager.BatchCreatePullRequestCommentsRequest(), + parent="parent_value", + requests=[ + secure_source_manager.CreatePullRequestCommentRequest( + parent="parent_value" + ) + ], + ) + + +@pytest.mark.asyncio +async def test_batch_create_pull_request_comments_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.batch_create_pull_request_comments( + parent="parent_value", + requests=[ + secure_source_manager.CreatePullRequestCommentRequest( + parent="parent_value" + ) + ], + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].requests + mock_val = [ + secure_source_manager.CreatePullRequestCommentRequest(parent="parent_value") + ] + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_batch_create_pull_request_comments_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.batch_create_pull_request_comments( + secure_source_manager.BatchCreatePullRequestCommentsRequest(), + parent="parent_value", + requests=[ + secure_source_manager.CreatePullRequestCommentRequest( + parent="parent_value" + ) + ], + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ResolvePullRequestCommentsRequest, + dict, + ], +) +def test_resolve_pull_request_comments(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.resolve_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.resolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ResolvePullRequestCommentsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_resolve_pull_request_comments_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.ResolvePullRequestCommentsRequest( + parent="parent_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.resolve_pull_request_comments), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.resolve_pull_request_comments(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.ResolvePullRequestCommentsRequest( + parent="parent_value", + ) + + +def test_resolve_pull_request_comments_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.resolve_pull_request_comments + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.resolve_pull_request_comments + ] = mock_rpc + request = {} + client.resolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.resolve_pull_request_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_resolve_pull_request_comments_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.resolve_pull_request_comments + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.resolve_pull_request_comments + ] = mock_rpc + + request = {} + await client.resolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.resolve_pull_request_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_resolve_pull_request_comments_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.ResolvePullRequestCommentsRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.resolve_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.resolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ResolvePullRequestCommentsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_resolve_pull_request_comments_async_from_dict(): + await test_resolve_pull_request_comments_async(request_type=dict) + + +def test_resolve_pull_request_comments_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ResolvePullRequestCommentsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.resolve_pull_request_comments), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.resolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_resolve_pull_request_comments_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ResolvePullRequestCommentsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.resolve_pull_request_comments), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.resolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_resolve_pull_request_comments_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.resolve_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.resolve_pull_request_comments( + parent="parent_value", + names=["names_value"], + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].names + mock_val = ["names_value"] + assert arg == mock_val + + +def test_resolve_pull_request_comments_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.resolve_pull_request_comments( + secure_source_manager.ResolvePullRequestCommentsRequest(), + parent="parent_value", + names=["names_value"], + ) + + +@pytest.mark.asyncio +async def test_resolve_pull_request_comments_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.resolve_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.resolve_pull_request_comments( + parent="parent_value", + names=["names_value"], + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].names + mock_val = ["names_value"] + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_resolve_pull_request_comments_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.resolve_pull_request_comments( + secure_source_manager.ResolvePullRequestCommentsRequest(), + parent="parent_value", + names=["names_value"], + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.UnresolvePullRequestCommentsRequest, + dict, + ], +) +def test_unresolve_pull_request_comments(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.unresolve_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.unresolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.UnresolvePullRequestCommentsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_unresolve_pull_request_comments_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.UnresolvePullRequestCommentsRequest( + parent="parent_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.unresolve_pull_request_comments), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.unresolve_pull_request_comments(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.UnresolvePullRequestCommentsRequest( + parent="parent_value", + ) + + +def test_unresolve_pull_request_comments_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.unresolve_pull_request_comments + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.unresolve_pull_request_comments + ] = mock_rpc + request = {} + client.unresolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.unresolve_pull_request_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_unresolve_pull_request_comments_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.unresolve_pull_request_comments + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.unresolve_pull_request_comments + ] = mock_rpc + + request = {} + await client.unresolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.unresolve_pull_request_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_unresolve_pull_request_comments_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.UnresolvePullRequestCommentsRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.unresolve_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.unresolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.UnresolvePullRequestCommentsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_unresolve_pull_request_comments_async_from_dict(): + await test_unresolve_pull_request_comments_async(request_type=dict) + + +def test_unresolve_pull_request_comments_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.UnresolvePullRequestCommentsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.unresolve_pull_request_comments), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.unresolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_unresolve_pull_request_comments_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.UnresolvePullRequestCommentsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.unresolve_pull_request_comments), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.unresolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_unresolve_pull_request_comments_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.unresolve_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.unresolve_pull_request_comments( + parent="parent_value", + names=["names_value"], + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].names + mock_val = ["names_value"] + assert arg == mock_val + + +def test_unresolve_pull_request_comments_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.unresolve_pull_request_comments( + secure_source_manager.UnresolvePullRequestCommentsRequest(), + parent="parent_value", + names=["names_value"], + ) + + +@pytest.mark.asyncio +async def test_unresolve_pull_request_comments_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.unresolve_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.unresolve_pull_request_comments( + parent="parent_value", + names=["names_value"], + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].names + mock_val = ["names_value"] + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_unresolve_pull_request_comments_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.unresolve_pull_request_comments( + secure_source_manager.UnresolvePullRequestCommentsRequest(), + parent="parent_value", + names=["names_value"], + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CreateIssueCommentRequest, + dict, + ], +) +def test_create_issue_comment(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.create_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.CreateIssueCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_issue_comment_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.CreateIssueCommentRequest( + parent="parent_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_comment), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.create_issue_comment(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.CreateIssueCommentRequest( + parent="parent_value", + ) + + +def test_create_issue_comment_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_issue_comment in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_issue_comment + ] = mock_rpc + request = {} + client.create_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_issue_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_issue_comment_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.create_issue_comment + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.create_issue_comment + ] = mock_rpc + + request = {} + await client.create_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.create_issue_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_create_issue_comment_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.CreateIssueCommentRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.create_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.CreateIssueCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_issue_comment_async_from_dict(): + await test_create_issue_comment_async(request_type=dict) + + +def test_create_issue_comment_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.CreateIssueCommentRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_comment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_issue_comment_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.CreateIssueCommentRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_comment), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.create_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_issue_comment_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_issue_comment( + parent="parent_value", + issue_comment=secure_source_manager.IssueComment(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].issue_comment + mock_val = secure_source_manager.IssueComment(name="name_value") + assert arg == mock_val + + +def test_create_issue_comment_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_issue_comment( + secure_source_manager.CreateIssueCommentRequest(), + parent="parent_value", + issue_comment=secure_source_manager.IssueComment(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_issue_comment_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_issue_comment( + parent="parent_value", + issue_comment=secure_source_manager.IssueComment(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].issue_comment + mock_val = secure_source_manager.IssueComment(name="name_value") + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_issue_comment_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_issue_comment( + secure_source_manager.CreateIssueCommentRequest(), + parent="parent_value", + issue_comment=secure_source_manager.IssueComment(name="name_value"), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetIssueCommentRequest, + dict, + ], +) +def test_get_issue_comment(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.IssueComment( + name="name_value", + body="body_value", + ) + response = client.get_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.GetIssueCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.IssueComment) + assert response.name == "name_value" + assert response.body == "body_value" + + +def test_get_issue_comment_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.GetIssueCommentRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_comment), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.get_issue_comment(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.GetIssueCommentRequest( + name="name_value", + ) + + +def test_get_issue_comment_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_issue_comment in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_issue_comment + ] = mock_rpc + request = {} + client.get_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_issue_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_issue_comment_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.get_issue_comment + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.get_issue_comment + ] = mock_rpc + + request = {} + await client.get_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_issue_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_get_issue_comment_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.GetIssueCommentRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.IssueComment( + name="name_value", + body="body_value", + ) + ) + response = await client.get_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.GetIssueCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.IssueComment) + assert response.name == "name_value" + assert response.body == "body_value" + + +@pytest.mark.asyncio +async def test_get_issue_comment_async_from_dict(): + await test_get_issue_comment_async(request_type=dict) + + +def test_get_issue_comment_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.GetIssueCommentRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_comment), "__call__" + ) as call: + call.return_value = secure_source_manager.IssueComment() + client.get_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_issue_comment_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.GetIssueCommentRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_comment), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.IssueComment() + ) + await client.get_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_issue_comment_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.IssueComment() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_issue_comment( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_issue_comment_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_issue_comment( + secure_source_manager.GetIssueCommentRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_issue_comment_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.IssueComment() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.IssueComment() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_issue_comment( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_issue_comment_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_issue_comment( + secure_source_manager.GetIssueCommentRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListIssueCommentsRequest, + dict, + ], +) +def test_list_issue_comments(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListIssueCommentsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_issue_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ListIssueCommentsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListIssueCommentsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_issue_comments_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.ListIssueCommentsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.list_issue_comments(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.ListIssueCommentsRequest( + parent="parent_value", + page_token="page_token_value", + ) + + +def test_list_issue_comments_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_issue_comments in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_issue_comments + ] = mock_rpc + request = {} + client.list_issue_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_issue_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_issue_comments_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.list_issue_comments + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.list_issue_comments + ] = mock_rpc + + request = {} + await client.list_issue_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_issue_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_list_issue_comments_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.ListIssueCommentsRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListIssueCommentsResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_issue_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.ListIssueCommentsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListIssueCommentsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_issue_comments_async_from_dict(): + await test_list_issue_comments_async(request_type=dict) + + +def test_list_issue_comments_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ListIssueCommentsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), "__call__" + ) as call: + call.return_value = secure_source_manager.ListIssueCommentsResponse() + client.list_issue_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_issue_comments_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.ListIssueCommentsRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListIssueCommentsResponse() + ) + await client.list_issue_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_issue_comments_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListIssueCommentsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_issue_comments( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_issue_comments_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issue_comments( + secure_source_manager.ListIssueCommentsRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_issue_comments_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = secure_source_manager.ListIssueCommentsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListIssueCommentsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_issue_comments( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_issue_comments_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_issue_comments( + secure_source_manager.ListIssueCommentsRequest(), + parent="parent_value", + ) + + +def test_list_issue_comments_pager(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + ], + next_page_token="abc", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[], + next_page_token="def", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_issue_comments(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.IssueComment) for i in results) + + +def test_list_issue_comments_pages(transport_name: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + ], + next_page_token="abc", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[], + next_page_token="def", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + ], + ), + RuntimeError, + ) + pages = list(client.list_issue_comments(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_issue_comments_async_pager(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + ], + next_page_token="abc", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[], + next_page_token="def", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_issue_comments( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, secure_source_manager.IssueComment) for i in responses) + + +@pytest.mark.asyncio +async def test_list_issue_comments_async_pages(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + ], + next_page_token="abc", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[], + next_page_token="def", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_issue_comments(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.UpdateIssueCommentRequest, + dict, + ], +) +def test_update_issue_comment(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.update_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.UpdateIssueCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_issue_comment_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.UpdateIssueCommentRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_comment), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.update_issue_comment(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.UpdateIssueCommentRequest() + + +def test_update_issue_comment_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_issue_comment in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_issue_comment + ] = mock_rpc + request = {} + client.update_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_issue_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_issue_comment_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.update_issue_comment + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.update_issue_comment + ] = mock_rpc + + request = {} + await client.update_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.update_issue_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_update_issue_comment_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.UpdateIssueCommentRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.update_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.UpdateIssueCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_issue_comment_async_from_dict(): + await test_update_issue_comment_async(request_type=dict) + + +def test_update_issue_comment_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.UpdateIssueCommentRequest() + + request.issue_comment.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_comment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "issue_comment.name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_issue_comment_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.UpdateIssueCommentRequest() + + request.issue_comment.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_comment), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.update_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "issue_comment.name=name_value", + ) in kw["metadata"] + + +def test_update_issue_comment_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_issue_comment( + issue_comment=secure_source_manager.IssueComment(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].issue_comment + mock_val = secure_source_manager.IssueComment(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +def test_update_issue_comment_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue_comment( + secure_source_manager.UpdateIssueCommentRequest(), + issue_comment=secure_source_manager.IssueComment(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_issue_comment_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_issue_comment( + issue_comment=secure_source_manager.IssueComment(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].issue_comment + mock_val = secure_source_manager.IssueComment(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_issue_comment_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_issue_comment( + secure_source_manager.UpdateIssueCommentRequest(), + issue_comment=secure_source_manager.IssueComment(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.DeleteIssueCommentRequest, + dict, + ], +) +def test_delete_issue_comment(request_type, transport: str = "grpc"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.delete_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = secure_source_manager.DeleteIssueCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_issue_comment_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = secure_source_manager.DeleteIssueCommentRequest( + name="name_value", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_comment), "__call__" + ) as call: + call.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client.delete_issue_comment(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == secure_source_manager.DeleteIssueCommentRequest( + name="name_value", + ) + + +def test_delete_issue_comment_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_issue_comment in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_issue_comment + ] = mock_rpc + request = {} + client.delete_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_issue_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_issue_comment_async_use_cached_wrapped_rpc( + transport: str = "grpc_asyncio", +): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._client._transport.delete_issue_comment + in client._client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[ + client._client._transport.delete_issue_comment + ] = mock_rpc + + request = {} + await client.delete_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.delete_issue_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +@pytest.mark.asyncio +async def test_delete_issue_comment_async( + transport: str = "grpc_asyncio", + request_type=secure_source_manager.DeleteIssueCommentRequest, +): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.delete_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = secure_source_manager.DeleteIssueCommentRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_issue_comment_async_from_dict(): + await test_delete_issue_comment_async(request_type=dict) + + +def test_delete_issue_comment_field_headers(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.DeleteIssueCommentRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_comment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_issue_comment_field_headers_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = secure_source_manager.DeleteIssueCommentRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_comment), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.delete_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_issue_comment_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_issue_comment( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_delete_issue_comment_flattened_error(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_issue_comment( + secure_source_manager.DeleteIssueCommentRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_issue_comment_flattened_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_issue_comment( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_issue_comment_flattened_error_async(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_issue_comment( + secure_source_manager.DeleteIssueCommentRequest(), + name="name_value", + ) + + +def test_list_instances_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_instances in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_instances] = mock_rpc + + request = {} + client.list_instances(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_instances(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_instances_rest_required_fields( + request_type=secure_source_manager.ListInstancesRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_instances._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_instances._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListInstancesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListInstancesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_instances(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_instances_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_instances._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_instances_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListInstancesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.ListInstancesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_instances(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/instances" % client.transport._host, + args[1], + ) + + +def test_list_instances_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_instances( + secure_source_manager.ListInstancesRequest(), + parent="parent_value", + ) + + +def test_list_instances_rest_pager(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + secure_source_manager.ListInstancesResponse( + instances=[ + secure_source_manager.Instance(), + secure_source_manager.Instance(), + secure_source_manager.Instance(), + ], + next_page_token="abc", + ), + secure_source_manager.ListInstancesResponse( + instances=[], + next_page_token="def", + ), + secure_source_manager.ListInstancesResponse( + instances=[ + secure_source_manager.Instance(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListInstancesResponse( + instances=[ + secure_source_manager.Instance(), + secure_source_manager.Instance(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + secure_source_manager.ListInstancesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_instances(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.Instance) for i in results) + + pages = list(client.list_instances(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_instance_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_instance in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_instance] = mock_rpc + + request = {} + client.get_instance(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_instance(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_instance_rest_required_fields( + request_type=secure_source_manager.GetInstanceRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_instance._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_instance._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.Instance() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.Instance.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_instance(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_instance_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_instance._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_instance_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.Instance() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/instances/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.Instance.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_instance(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/instances/*}" % client.transport._host, + args[1], + ) + + +def test_get_instance_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_instance( + secure_source_manager.GetInstanceRequest(), + name="name_value", + ) + + +def test_create_instance_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_instance in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.create_instance] = mock_rpc + + request = {} + client.create_instance(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_instance(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_instance_rest_required_fields( + request_type=secure_source_manager.CreateInstanceRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["instance_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + assert "instanceId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_instance._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "instanceId" in jsonified_request + assert jsonified_request["instanceId"] == request_init["instance_id"] + + jsonified_request["parent"] = "parent_value" + jsonified_request["instanceId"] = "instance_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_instance._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "instance_id", + "request_id", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "instanceId" in jsonified_request + assert jsonified_request["instanceId"] == "instance_id_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_instance(request) + + expected_params = [ + ( + "instanceId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_instance_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_instance._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "instanceId", + "requestId", + ) + ) + & set( + ( + "parent", + "instanceId", + "instance", + ) + ) + ) + + +def test_create_instance_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + instance=secure_source_manager.Instance(name="name_value"), + instance_id="instance_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_instance(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/instances" % client.transport._host, + args[1], + ) + + +def test_create_instance_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_instance( + secure_source_manager.CreateInstanceRequest(), + parent="parent_value", + instance=secure_source_manager.Instance(name="name_value"), + instance_id="instance_id_value", + ) + + +def test_delete_instance_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_instance in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_instance] = mock_rpc + + request = {} + client.delete_instance(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_instance(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_instance_rest_required_fields( + request_type=secure_source_manager.DeleteInstanceRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_instance._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_instance._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_instance(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_instance_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_instance._get_unset_required_fields({}) + assert set(unset_fields) == (set(("requestId",)) & set(("name",))) + + +def test_delete_instance_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/instances/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_instance(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/instances/*}" % client.transport._host, + args[1], + ) + + +def test_delete_instance_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_instance( + secure_source_manager.DeleteInstanceRequest(), + name="name_value", + ) + + +def test_list_repositories_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_repositories in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_repositories + ] = mock_rpc + + request = {} + client.list_repositories(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_repositories(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_repositories_rest_required_fields( + request_type=secure_source_manager.ListRepositoriesRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_repositories._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_repositories._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "instance", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListRepositoriesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListRepositoriesResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_repositories(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_repositories_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_repositories._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "instance", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_repositories_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListRepositoriesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.ListRepositoriesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_repositories(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/repositories" + % client.transport._host, + args[1], + ) + + +def test_list_repositories_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_repositories( + secure_source_manager.ListRepositoriesRequest(), + parent="parent_value", + ) + + +def test_list_repositories_rest_pager(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + secure_source_manager.ListRepositoriesResponse( + repositories=[ + secure_source_manager.Repository(), + secure_source_manager.Repository(), + secure_source_manager.Repository(), + ], + next_page_token="abc", + ), + secure_source_manager.ListRepositoriesResponse( + repositories=[], + next_page_token="def", + ), + secure_source_manager.ListRepositoriesResponse( + repositories=[ + secure_source_manager.Repository(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListRepositoriesResponse( + repositories=[ + secure_source_manager.Repository(), + secure_source_manager.Repository(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + secure_source_manager.ListRepositoriesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_repositories(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.Repository) for i in results) + + pages = list(client.list_repositories(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_repository_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_repository in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_repository] = mock_rpc + + request = {} + client.get_repository(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_repository(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_repository_rest_required_fields( + request_type=secure_source_manager.GetRepositoryRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_repository._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_repository._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.Repository() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.Repository.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_repository(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_repository_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_repository._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_repository_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.Repository() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.Repository.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_repository(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*}" + % client.transport._host, + args[1], + ) + + +def test_get_repository_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_repository( + secure_source_manager.GetRepositoryRequest(), + name="name_value", + ) + + +def test_create_repository_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_repository in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_repository + ] = mock_rpc + + request = {} + client.create_repository(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_repository(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_repository_rest_required_fields( + request_type=secure_source_manager.CreateRepositoryRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["repository_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + assert "repositoryId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_repository._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "repositoryId" in jsonified_request + assert jsonified_request["repositoryId"] == request_init["repository_id"] + + jsonified_request["parent"] = "parent_value" + jsonified_request["repositoryId"] = "repository_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_repository._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("repository_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "repositoryId" in jsonified_request + assert jsonified_request["repositoryId"] == "repository_id_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_repository(request) + + expected_params = [ + ( + "repositoryId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_repository_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_repository._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("repositoryId",)) + & set( + ( + "parent", + "repository", + "repositoryId", + ) + ) + ) + + +def test_create_repository_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + repository=secure_source_manager.Repository(name="name_value"), + repository_id="repository_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_repository(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/repositories" + % client.transport._host, + args[1], + ) + + +def test_create_repository_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_repository( + secure_source_manager.CreateRepositoryRequest(), + parent="parent_value", + repository=secure_source_manager.Repository(name="name_value"), + repository_id="repository_id_value", + ) + + +def test_update_repository_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_repository in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_repository + ] = mock_rpc + + request = {} + client.update_repository(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_repository(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_repository_rest_required_fields( + request_type=secure_source_manager.UpdateRepositoryRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_repository._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_repository._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "update_mask", + "validate_only", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_repository(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_repository_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_repository._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "updateMask", + "validateOnly", + ) + ) + & set(("repository",)) + ) + + +def test_update_repository_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "repository": { + "name": "projects/sample1/locations/sample2/repositories/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + repository=secure_source_manager.Repository(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_repository(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{repository.name=projects/*/locations/*/repositories/*}" + % client.transport._host, + args[1], + ) + + +def test_update_repository_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_repository( + secure_source_manager.UpdateRepositoryRequest(), + repository=secure_source_manager.Repository(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_repository_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_repository in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_repository + ] = mock_rpc + + request = {} + client.delete_repository(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_repository(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_repository_rest_required_fields( + request_type=secure_source_manager.DeleteRepositoryRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_repository._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_repository._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("allow_missing",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_repository(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_repository_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_repository._get_unset_required_fields({}) + assert set(unset_fields) == (set(("allowMissing",)) & set(("name",))) + + +def test_delete_repository_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_repository(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_repository_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_repository( + secure_source_manager.DeleteRepositoryRequest(), + name="name_value", + ) + + +def test_list_hooks_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_hooks in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_hooks] = mock_rpc + + request = {} + client.list_hooks(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_hooks(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_hooks_rest_required_fields( + request_type=secure_source_manager.ListHooksRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_hooks._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_hooks._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListHooksResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListHooksResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_hooks(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_hooks_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_hooks._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_hooks_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListHooksResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.ListHooksResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_hooks(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/hooks" + % client.transport._host, + args[1], + ) + + +def test_list_hooks_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_hooks( + secure_source_manager.ListHooksRequest(), + parent="parent_value", + ) + + +def test_list_hooks_rest_pager(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + secure_source_manager.Hook(), + secure_source_manager.Hook(), + ], + next_page_token="abc", + ), + secure_source_manager.ListHooksResponse( + hooks=[], + next_page_token="def", + ), + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListHooksResponse( + hooks=[ + secure_source_manager.Hook(), + secure_source_manager.Hook(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + secure_source_manager.ListHooksResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + pager = client.list_hooks(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.Hook) for i in results) + + pages = list(client.list_hooks(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_hook_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_hook in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_hook] = mock_rpc + + request = {} + client.get_hook(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_hook(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_hook_rest_required_fields( + request_type=secure_source_manager.GetHookRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_hook._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_hook._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.Hook() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.Hook.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_hook(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_hook_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_hook._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_hook_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.Hook() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/hooks/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.Hook.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_hook(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/hooks/*}" + % client.transport._host, + args[1], + ) + + +def test_get_hook_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_hook( + secure_source_manager.GetHookRequest(), + name="name_value", + ) + + +def test_create_hook_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_hook in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.create_hook] = mock_rpc + + request = {} + client.create_hook(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_hook(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_hook_rest_required_fields( + request_type=secure_source_manager.CreateHookRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["hook_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + assert "hookId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_hook._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "hookId" in jsonified_request + assert jsonified_request["hookId"] == request_init["hook_id"] + + jsonified_request["parent"] = "parent_value" + jsonified_request["hookId"] = "hook_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_hook._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("hook_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "hookId" in jsonified_request + assert jsonified_request["hookId"] == "hook_id_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_hook(request) + + expected_params = [ + ( + "hookId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_hook_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_hook._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("hookId",)) + & set( + ( + "parent", + "hook", + "hookId", + ) + ) + ) + + +def test_create_hook_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + hook=secure_source_manager.Hook(name="name_value"), + hook_id="hook_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_hook(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/hooks" + % client.transport._host, + args[1], + ) + + +def test_create_hook_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_hook( + secure_source_manager.CreateHookRequest(), + parent="parent_value", + hook=secure_source_manager.Hook(name="name_value"), + hook_id="hook_id_value", + ) + + +def test_update_hook_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_hook in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_hook] = mock_rpc + + request = {} + client.update_hook(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_hook(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_hook_rest_required_fields( + request_type=secure_source_manager.UpdateHookRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_hook._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_hook._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_hook(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_hook_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_hook._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "updateMask", + "hook", + ) + ) + ) + + +def test_update_hook_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "hook": { + "name": "projects/sample1/locations/sample2/repositories/sample3/hooks/sample4" + } + } + + # get truthy value for each flattened field + mock_args = dict( + hook=secure_source_manager.Hook(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_hook(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{hook.name=projects/*/locations/*/repositories/*/hooks/*}" + % client.transport._host, + args[1], + ) + + +def test_update_hook_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_hook( + secure_source_manager.UpdateHookRequest(), + hook=secure_source_manager.Hook(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_hook_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_hook in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_hook] = mock_rpc + + request = {} + client.delete_hook(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_hook(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_hook_rest_required_fields( + request_type=secure_source_manager.DeleteHookRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_hook._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_hook._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_hook(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_hook_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_hook._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_hook_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/hooks/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_hook(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/hooks/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_hook_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_hook( + secure_source_manager.DeleteHookRequest(), + name="name_value", + ) + + +def test_get_iam_policy_repo_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_iam_policy_repo in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_iam_policy_repo + ] = mock_rpc + + request = {} + client.get_iam_policy_repo(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_iam_policy_repo(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_iam_policy_repo_rest_required_fields( + request_type=iam_policy_pb2.GetIamPolicyRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["resource"] = "" + request = request_type(**request_init) + pb_request = request + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_iam_policy_repo._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["resource"] = "resource_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_iam_policy_repo._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("options",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "resource" in jsonified_request + assert jsonified_request["resource"] == "resource_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = policy_pb2.Policy() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_iam_policy_repo(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_iam_policy_repo_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_iam_policy_repo._get_unset_required_fields({}) + assert set(unset_fields) == (set(("options",)) & set(("resource",))) + + +def test_get_iam_policy_repo_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = policy_pb2.Policy() + + # get arguments that satisfy an http rule for this method + sample_request = { + "resource": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + resource="resource_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_iam_policy_repo(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{resource=projects/*/locations/*/repositories/*}:getIamPolicy" + % client.transport._host, + args[1], + ) + + +def test_get_iam_policy_repo_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_iam_policy_repo( + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", + ) + + +def test_set_iam_policy_repo_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.set_iam_policy_repo in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.set_iam_policy_repo + ] = mock_rpc + + request = {} + client.set_iam_policy_repo(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.set_iam_policy_repo(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_set_iam_policy_repo_rest_required_fields( + request_type=iam_policy_pb2.SetIamPolicyRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["resource"] = "" + request = request_type(**request_init) + pb_request = request + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).set_iam_policy_repo._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["resource"] = "resource_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).set_iam_policy_repo._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "resource" in jsonified_request + assert jsonified_request["resource"] == "resource_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = policy_pb2.Policy() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.set_iam_policy_repo(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_set_iam_policy_repo_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.set_iam_policy_repo._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "resource", + "policy", + ) + ) + ) + + +def test_set_iam_policy_repo_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = policy_pb2.Policy() + + # get arguments that satisfy an http rule for this method + sample_request = { + "resource": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + resource="resource_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.set_iam_policy_repo(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{resource=projects/*/locations/*/repositories/*}:setIamPolicy" + % client.transport._host, + args[1], + ) + + +def test_set_iam_policy_repo_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.set_iam_policy_repo( + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", + ) + + +def test_test_iam_permissions_repo_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.test_iam_permissions_repo + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.test_iam_permissions_repo + ] = mock_rpc + + request = {} + client.test_iam_permissions_repo(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.test_iam_permissions_repo(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_test_iam_permissions_repo_rest_required_fields( + request_type=iam_policy_pb2.TestIamPermissionsRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["resource"] = "" + request_init["permissions"] = "" + request = request_type(**request_init) + pb_request = request + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).test_iam_permissions_repo._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["resource"] = "resource_value" + jsonified_request["permissions"] = "permissions_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).test_iam_permissions_repo._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "resource" in jsonified_request + assert jsonified_request["resource"] == "resource_value" + assert "permissions" in jsonified_request + assert jsonified_request["permissions"] == "permissions_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = iam_policy_pb2.TestIamPermissionsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.test_iam_permissions_repo(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_test_iam_permissions_repo_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.test_iam_permissions_repo._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "resource", + "permissions", + ) + ) + ) + + +def test_test_iam_permissions_repo_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = iam_policy_pb2.TestIamPermissionsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "resource": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + resource="resource_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.test_iam_permissions_repo(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{resource=projects/*/locations/*/repositories/*}:testIamPermissions" + % client.transport._host, + args[1], + ) + + +def test_test_iam_permissions_repo_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.test_iam_permissions_repo( + iam_policy_pb2.TestIamPermissionsRequest(), + resource="resource_value", + ) + + +def test_create_branch_rule_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_branch_rule in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_branch_rule + ] = mock_rpc + + request = {} + client.create_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_branch_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_branch_rule_rest_required_fields( + request_type=secure_source_manager.CreateBranchRuleRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["branch_rule_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + assert "branchRuleId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_branch_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "branchRuleId" in jsonified_request + assert jsonified_request["branchRuleId"] == request_init["branch_rule_id"] + + jsonified_request["parent"] = "parent_value" + jsonified_request["branchRuleId"] = "branch_rule_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_branch_rule._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("branch_rule_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "branchRuleId" in jsonified_request + assert jsonified_request["branchRuleId"] == "branch_rule_id_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_branch_rule(request) + + expected_params = [ + ( + "branchRuleId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_branch_rule_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_branch_rule._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("branchRuleId",)) + & set( + ( + "parent", + "branchRule", + "branchRuleId", + ) + ) + ) + + +def test_create_branch_rule_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + branch_rule=secure_source_manager.BranchRule(name="name_value"), + branch_rule_id="branch_rule_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_branch_rule(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/branchRules" + % client.transport._host, + args[1], + ) + + +def test_create_branch_rule_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_branch_rule( + secure_source_manager.CreateBranchRuleRequest(), + parent="parent_value", + branch_rule=secure_source_manager.BranchRule(name="name_value"), + branch_rule_id="branch_rule_id_value", + ) + + +def test_list_branch_rules_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_branch_rules in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_branch_rules + ] = mock_rpc + + request = {} + client.list_branch_rules(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_branch_rules(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_branch_rules_rest_required_fields( + request_type=secure_source_manager.ListBranchRulesRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_branch_rules._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_branch_rules._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListBranchRulesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListBranchRulesResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_branch_rules(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_branch_rules_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_branch_rules._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_branch_rules_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListBranchRulesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.ListBranchRulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_branch_rules(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/branchRules" + % client.transport._host, + args[1], + ) + + +def test_list_branch_rules_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_branch_rules( + secure_source_manager.ListBranchRulesRequest(), + parent="parent_value", + ) + + +def test_list_branch_rules_rest_pager(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + ], + next_page_token="abc", + ), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[], + next_page_token="def", + ), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListBranchRulesResponse( + branch_rules=[ + secure_source_manager.BranchRule(), + secure_source_manager.BranchRule(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + secure_source_manager.ListBranchRulesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + pager = client.list_branch_rules(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.BranchRule) for i in results) + + pages = list(client.list_branch_rules(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_branch_rule_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_branch_rule in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_branch_rule] = mock_rpc + + request = {} + client.get_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_branch_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_branch_rule_rest_required_fields( + request_type=secure_source_manager.GetBranchRuleRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_branch_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_branch_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.BranchRule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.BranchRule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_branch_rule(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_branch_rule_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_branch_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_branch_rule_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.BranchRule() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.BranchRule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_branch_rule(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/branchRules/*}" + % client.transport._host, + args[1], + ) + + +def test_get_branch_rule_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_branch_rule( + secure_source_manager.GetBranchRuleRequest(), + name="name_value", + ) + + +def test_update_branch_rule_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_branch_rule in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_branch_rule + ] = mock_rpc + + request = {} + client.update_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_branch_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_branch_rule_rest_required_fields( + request_type=secure_source_manager.UpdateBranchRuleRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_branch_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_branch_rule._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "update_mask", + "validate_only", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_branch_rule(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_branch_rule_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_branch_rule._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "updateMask", + "validateOnly", + ) + ) + & set( + ( + "branchRule", + "updateMask", + ) + ) + ) + + +def test_update_branch_rule_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "branch_rule": { + "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" + } + } + + # get truthy value for each flattened field + mock_args = dict( + branch_rule=secure_source_manager.BranchRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_branch_rule(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{branch_rule.name=projects/*/locations/*/repositories/*/branchRules/*}" + % client.transport._host, + args[1], + ) + + +def test_update_branch_rule_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_branch_rule( + secure_source_manager.UpdateBranchRuleRequest(), + branch_rule=secure_source_manager.BranchRule(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_branch_rule_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_branch_rule in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_branch_rule + ] = mock_rpc + + request = {} + client.delete_branch_rule(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_branch_rule(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_branch_rule_rest_required_fields( + request_type=secure_source_manager.DeleteBranchRuleRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_branch_rule._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_branch_rule._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("allow_missing",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_branch_rule(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_branch_rule_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_branch_rule._get_unset_required_fields({}) + assert set(unset_fields) == (set(("allowMissing",)) & set(("name",))) + + +def test_delete_branch_rule_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_branch_rule(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/branchRules/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_branch_rule_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_branch_rule( + secure_source_manager.DeleteBranchRuleRequest(), + name="name_value", + ) + + +def test_create_pull_request_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_pull_request in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_pull_request + ] = mock_rpc + + request = {} + client.create_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_pull_request_rest_required_fields( + request_type=secure_source_manager.CreatePullRequestRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_pull_request._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_pull_request._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_pull_request(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_pull_request_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_pull_request._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "pullRequest", + ) + ) + ) + + +def test_create_pull_request_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + pull_request=secure_source_manager.PullRequest(name="name_value"), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_pull_request(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/pullRequests" + % client.transport._host, + args[1], + ) + + +def test_create_pull_request_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_pull_request( + secure_source_manager.CreatePullRequestRequest(), + parent="parent_value", + pull_request=secure_source_manager.PullRequest(name="name_value"), + ) + + +def test_get_pull_request_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_pull_request in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_pull_request + ] = mock_rpc + + request = {} + client.get_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_pull_request_rest_required_fields( + request_type=secure_source_manager.GetPullRequestRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_pull_request._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_pull_request._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.PullRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.PullRequest.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_pull_request(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_pull_request_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_pull_request._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_pull_request_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.PullRequest() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.PullRequest.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_pull_request(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*}" + % client.transport._host, + args[1], + ) + + +def test_get_pull_request_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_pull_request( + secure_source_manager.GetPullRequestRequest(), + name="name_value", + ) + + +def test_list_pull_requests_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_pull_requests in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_pull_requests + ] = mock_rpc + + request = {} + client.list_pull_requests(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_pull_requests(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_pull_requests_rest_required_fields( + request_type=secure_source_manager.ListPullRequestsRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_pull_requests._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_pull_requests._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListPullRequestsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListPullRequestsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_pull_requests(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_pull_requests_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_pull_requests._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_pull_requests_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListPullRequestsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.ListPullRequestsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_pull_requests(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/pullRequests" + % client.transport._host, + args[1], + ) + + +def test_list_pull_requests_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_pull_requests( + secure_source_manager.ListPullRequestsRequest(), + parent="parent_value", + ) + + +def test_list_pull_requests_rest_pager(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestsResponse( + pull_requests=[ + secure_source_manager.PullRequest(), + secure_source_manager.PullRequest(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + secure_source_manager.ListPullRequestsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + pager = client.list_pull_requests(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.PullRequest) for i in results) + + pages = list(client.list_pull_requests(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_update_pull_request_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_pull_request in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_pull_request + ] = mock_rpc + + request = {} + client.update_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_pull_request_rest_required_fields( + request_type=secure_source_manager.UpdatePullRequestRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_pull_request._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_pull_request._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_pull_request(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_pull_request_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_pull_request._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("pullRequest",))) + + +def test_update_pull_request_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "pull_request": { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + } + + # get truthy value for each flattened field + mock_args = dict( + pull_request=secure_source_manager.PullRequest(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_pull_request(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{pull_request.name=projects/*/locations/*/repositories/*/pullRequests/*}" + % client.transport._host, + args[1], + ) + + +def test_update_pull_request_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_pull_request( + secure_source_manager.UpdatePullRequestRequest(), + pull_request=secure_source_manager.PullRequest(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_merge_pull_request_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.merge_pull_request in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.merge_pull_request + ] = mock_rpc + + request = {} + client.merge_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.merge_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_merge_pull_request_rest_required_fields( + request_type=secure_source_manager.MergePullRequestRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).merge_pull_request._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).merge_pull_request._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.merge_pull_request(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_merge_pull_request_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.merge_pull_request._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_merge_pull_request_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.merge_pull_request(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*}:merge" + % client.transport._host, + args[1], + ) + + +def test_merge_pull_request_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.merge_pull_request( + secure_source_manager.MergePullRequestRequest(), + name="name_value", + ) + + +def test_open_pull_request_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.open_pull_request in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.open_pull_request + ] = mock_rpc + + request = {} + client.open_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.open_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_open_pull_request_rest_required_fields( + request_type=secure_source_manager.OpenPullRequestRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).open_pull_request._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).open_pull_request._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.open_pull_request(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_open_pull_request_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.open_pull_request._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_open_pull_request_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.open_pull_request(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*}:open" + % client.transport._host, + args[1], + ) + + +def test_open_pull_request_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.open_pull_request( + secure_source_manager.OpenPullRequestRequest(), + name="name_value", + ) + + +def test_close_pull_request_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.close_pull_request in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.close_pull_request + ] = mock_rpc + + request = {} + client.close_pull_request(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.close_pull_request(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_close_pull_request_rest_required_fields( + request_type=secure_source_manager.ClosePullRequestRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).close_pull_request._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).close_pull_request._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.close_pull_request(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_close_pull_request_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.close_pull_request._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_close_pull_request_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.close_pull_request(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*}:close" + % client.transport._host, + args[1], + ) + + +def test_close_pull_request_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.close_pull_request( + secure_source_manager.ClosePullRequestRequest(), + name="name_value", + ) + + +def test_list_pull_request_file_diffs_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_pull_request_file_diffs + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_pull_request_file_diffs + ] = mock_rpc + + request = {} + client.list_pull_request_file_diffs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_pull_request_file_diffs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_pull_request_file_diffs_rest_required_fields( + request_type=secure_source_manager.ListPullRequestFileDiffsRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_pull_request_file_diffs._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_pull_request_file_diffs._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListPullRequestFileDiffsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListPullRequestFileDiffsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_pull_request_file_diffs(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_pull_request_file_diffs_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_pull_request_file_diffs._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("name",)) + ) + + +def test_list_pull_request_file_diffs_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListPullRequestFileDiffsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.ListPullRequestFileDiffsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_pull_request_file_diffs(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*}:listFileDiffs" + % client.transport._host, + args[1], + ) + + +def test_list_pull_request_file_diffs_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_pull_request_file_diffs( + secure_source_manager.ListPullRequestFileDiffsRequest(), + name="name_value", + ) + + +def test_list_pull_request_file_diffs_rest_pager(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestFileDiffsResponse( + file_diffs=[ + secure_source_manager.FileDiff(), + secure_source_manager.FileDiff(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + secure_source_manager.ListPullRequestFileDiffsResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + + pager = client.list_pull_request_file_diffs(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.FileDiff) for i in results) + + pages = list(client.list_pull_request_file_diffs(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_fetch_tree_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.fetch_tree in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.fetch_tree] = mock_rpc + + request = {} + client.fetch_tree(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.fetch_tree(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_fetch_tree_rest_required_fields( + request_type=secure_source_manager.FetchTreeRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["repository"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).fetch_tree._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["repository"] = "repository_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).fetch_tree._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + "recursive", + "ref", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "repository" in jsonified_request + assert jsonified_request["repository"] == "repository_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.FetchTreeResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.FetchTreeResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.fetch_tree(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_fetch_tree_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.fetch_tree._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + "recursive", + "ref", + ) + ) + & set(("repository",)) + ) + + +def test_fetch_tree_rest_pager(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + ], + next_page_token="abc", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[], + next_page_token="def", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + ], + next_page_token="ghi", + ), + secure_source_manager.FetchTreeResponse( + tree_entries=[ + secure_source_manager.TreeEntry(), + secure_source_manager.TreeEntry(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + secure_source_manager.FetchTreeResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "repository": "projects/sample1/locations/sample2/repositories/sample3" + } + + pager = client.fetch_tree(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.TreeEntry) for i in results) + + pages = list(client.fetch_tree(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_fetch_blob_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.fetch_blob in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.fetch_blob] = mock_rpc + + request = {} + client.fetch_blob(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.fetch_blob(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_fetch_blob_rest_required_fields( + request_type=secure_source_manager.FetchBlobRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["repository"] = "" + request_init["sha"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + assert "sha" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).fetch_blob._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "sha" in jsonified_request + assert jsonified_request["sha"] == request_init["sha"] + + jsonified_request["repository"] = "repository_value" + jsonified_request["sha"] = "sha_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).fetch_blob._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("sha",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "repository" in jsonified_request + assert jsonified_request["repository"] == "repository_value" + assert "sha" in jsonified_request + assert jsonified_request["sha"] == "sha_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.FetchBlobResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.FetchBlobResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.fetch_blob(request) + + expected_params = [ + ( + "sha", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_fetch_blob_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.fetch_blob._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("sha",)) + & set( + ( + "repository", + "sha", + ) + ) + ) + + +def test_create_issue_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.create_issue] = mock_rpc + + request = {} + client.create_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_issue_rest_required_fields( + request_type=secure_source_manager.CreateIssueRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_issue(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_issue_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_issue._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "issue", + ) + ) + ) + + +def test_create_issue_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + issue=secure_source_manager.Issue(name="name_value"), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_issue(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/issues" + % client.transport._host, + args[1], + ) + + +def test_create_issue_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_issue( + secure_source_manager.CreateIssueRequest(), + parent="parent_value", + issue=secure_source_manager.Issue(name="name_value"), + ) + + +def test_get_issue_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_issue] = mock_rpc + + request = {} + client.get_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_issue_rest_required_fields( + request_type=secure_source_manager.GetIssueRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.Issue() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_issue(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_issue_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_issue._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_issue_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.Issue() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_issue(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/issues/*}" + % client.transport._host, + args[1], + ) + + +def test_get_issue_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_issue( + secure_source_manager.GetIssueRequest(), + name="name_value", + ) + + +def test_list_issues_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_issues in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_issues] = mock_rpc + + request = {} + client.list_issues(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_issues(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_issues_rest_required_fields( + request_type=secure_source_manager.ListIssuesRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_issues._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_issues._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListIssuesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListIssuesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_issues(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_issues_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_issues._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_issues_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListIssuesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.ListIssuesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_issues(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*}/issues" + % client.transport._host, + args[1], + ) + + +def test_list_issues_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issues( + secure_source_manager.ListIssuesRequest(), + parent="parent_value", + ) + + +def test_list_issues_rest_pager(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + secure_source_manager.Issue(), + secure_source_manager.Issue(), + ], + next_page_token="abc", + ), + secure_source_manager.ListIssuesResponse( + issues=[], + next_page_token="def", + ), + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListIssuesResponse( + issues=[ + secure_source_manager.Issue(), + secure_source_manager.Issue(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + secure_source_manager.ListIssuesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3" + } + + pager = client.list_issues(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.Issue) for i in results) + + pages = list(client.list_issues(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_update_issue_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_issue] = mock_rpc + + request = {} + client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_issue_rest_required_fields( + request_type=secure_source_manager.UpdateIssueRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_issue._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_issue(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_issue_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_issue._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("issue",))) + + +def test_update_issue_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "issue": { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + } + + # get truthy value for each flattened field + mock_args = dict( + issue=secure_source_manager.Issue(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_issue(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{issue.name=projects/*/locations/*/repositories/*/issues/*}" + % client.transport._host, + args[1], + ) + + +def test_update_issue_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue( + secure_source_manager.UpdateIssueRequest(), + issue=secure_source_manager.Issue(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_issue_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_issue] = mock_rpc + + request = {} + client.delete_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_issue_rest_required_fields( + request_type=secure_source_manager.DeleteIssueRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_issue._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("etag",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_issue(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_issue_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_issue._get_unset_required_fields({}) + assert set(unset_fields) == (set(("etag",)) & set(("name",))) + + +def test_delete_issue_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_issue(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/issues/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_issue_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_issue( + secure_source_manager.DeleteIssueRequest(), + name="name_value", + ) + + +def test_open_issue_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.open_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.open_issue] = mock_rpc + + request = {} + client.open_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.open_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_open_issue_rest_required_fields( + request_type=secure_source_manager.OpenIssueRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).open_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).open_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.open_issue(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_open_issue_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.open_issue._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_open_issue_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.open_issue(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/issues/*}:open" + % client.transport._host, + args[1], + ) + + +def test_open_issue_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.open_issue( + secure_source_manager.OpenIssueRequest(), + name="name_value", + ) + + +def test_close_issue_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.close_issue in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.close_issue] = mock_rpc + + request = {} + client.close_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.close_issue(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_close_issue_rest_required_fields( + request_type=secure_source_manager.CloseIssueRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).close_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).close_issue._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.close_issue(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_close_issue_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.close_issue._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_close_issue_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.close_issue(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/issues/*}:close" + % client.transport._host, + args[1], + ) + + +def test_close_issue_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.close_issue( + secure_source_manager.CloseIssueRequest(), + name="name_value", + ) + + +def test_get_pull_request_comment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_pull_request_comment + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_pull_request_comment + ] = mock_rpc + + request = {} + client.get_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_pull_request_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_pull_request_comment_rest_required_fields( + request_type=secure_source_manager.GetPullRequestCommentRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_pull_request_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_pull_request_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.PullRequestComment() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.PullRequestComment.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_pull_request_comment(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_pull_request_comment_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_pull_request_comment._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_pull_request_comment_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.PullRequestComment() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4/pullRequestComments/sample5" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.PullRequestComment.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_pull_request_comment(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*/pullRequestComments/*}" + % client.transport._host, + args[1], + ) + + +def test_get_pull_request_comment_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_pull_request_comment( + secure_source_manager.GetPullRequestCommentRequest(), + name="name_value", + ) + + +def test_list_pull_request_comments_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_pull_request_comments + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_pull_request_comments + ] = mock_rpc + + request = {} + client.list_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_pull_request_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_pull_request_comments_rest_required_fields( + request_type=secure_source_manager.ListPullRequestCommentsRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_pull_request_comments._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_pull_request_comments._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListPullRequestCommentsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListPullRequestCommentsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_pull_request_comments(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_pull_request_comments_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_pull_request_comments._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_pull_request_comments_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListPullRequestCommentsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.ListPullRequestCommentsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_pull_request_comments(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*/pullRequests/*}/pullRequestComments" + % client.transport._host, + args[1], + ) + + +def test_list_pull_request_comments_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_pull_request_comments( + secure_source_manager.ListPullRequestCommentsRequest(), + parent="parent_value", + ) + + +def test_list_pull_request_comments_rest_pager(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + ], + next_page_token="abc", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[], + next_page_token="def", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListPullRequestCommentsResponse( + pull_request_comments=[ + secure_source_manager.PullRequestComment(), + secure_source_manager.PullRequestComment(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + secure_source_manager.ListPullRequestCommentsResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + + pager = client.list_pull_request_comments(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all( + isinstance(i, secure_source_manager.PullRequestComment) for i in results + ) + + pages = list(client.list_pull_request_comments(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_create_pull_request_comment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_pull_request_comment + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_pull_request_comment + ] = mock_rpc + + request = {} + client.create_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_pull_request_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_pull_request_comment_rest_required_fields( + request_type=secure_source_manager.CreatePullRequestCommentRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_pull_request_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_pull_request_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_pull_request_comment(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_pull_request_comment_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_pull_request_comment._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "pullRequestComment", + ) + ) + ) + + +def test_create_pull_request_comment_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + pull_request_comment=secure_source_manager.PullRequestComment( + name="name_value" + ), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_pull_request_comment(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*/pullRequests/*}/pullRequestComments" + % client.transport._host, + args[1], + ) + + +def test_create_pull_request_comment_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_pull_request_comment( + secure_source_manager.CreatePullRequestCommentRequest(), + parent="parent_value", + pull_request_comment=secure_source_manager.PullRequestComment( + name="name_value" + ), + ) + + +def test_update_pull_request_comment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_pull_request_comment + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_pull_request_comment + ] = mock_rpc + + request = {} + client.update_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_pull_request_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_pull_request_comment_rest_required_fields( + request_type=secure_source_manager.UpdatePullRequestCommentRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_pull_request_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_pull_request_comment._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_pull_request_comment(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_pull_request_comment_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_pull_request_comment._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("pullRequestComment",))) + + +def test_update_pull_request_comment_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "pull_request_comment": { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4/pullRequestComments/sample5" + } + } + + # get truthy value for each flattened field + mock_args = dict( + pull_request_comment=secure_source_manager.PullRequestComment( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_pull_request_comment(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{pull_request_comment.name=projects/*/locations/*/repositories/*/pullRequests/*/pullRequestComments/*}" + % client.transport._host, + args[1], + ) + + +def test_update_pull_request_comment_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_pull_request_comment( + secure_source_manager.UpdatePullRequestCommentRequest(), + pull_request_comment=secure_source_manager.PullRequestComment( + name="name_value" + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_pull_request_comment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_pull_request_comment + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_pull_request_comment + ] = mock_rpc + + request = {} + client.delete_pull_request_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_pull_request_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_pull_request_comment_rest_required_fields( + request_type=secure_source_manager.DeletePullRequestCommentRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_pull_request_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_pull_request_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_pull_request_comment(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_pull_request_comment_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_pull_request_comment._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_pull_request_comment_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4/pullRequestComments/sample5" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_pull_request_comment(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/pullRequests/*/pullRequestComments/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_pull_request_comment_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_pull_request_comment( + secure_source_manager.DeletePullRequestCommentRequest(), + name="name_value", + ) + + +def test_batch_create_pull_request_comments_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.batch_create_pull_request_comments + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.batch_create_pull_request_comments + ] = mock_rpc + + request = {} + client.batch_create_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.batch_create_pull_request_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_batch_create_pull_request_comments_rest_required_fields( + request_type=secure_source_manager.BatchCreatePullRequestCommentsRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_create_pull_request_comments._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_create_pull_request_comments._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.batch_create_pull_request_comments(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_batch_create_pull_request_comments_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = ( + transport.batch_create_pull_request_comments._get_unset_required_fields({}) + ) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "requests", + ) + ) + ) + + +def test_batch_create_pull_request_comments_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + requests=[ + secure_source_manager.CreatePullRequestCommentRequest( + parent="parent_value" + ) + ], + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.batch_create_pull_request_comments(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*/pullRequests/*}/pullRequestComments:batchCreate" + % client.transport._host, + args[1], + ) + + +def test_batch_create_pull_request_comments_rest_flattened_error( + transport: str = "rest", +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.batch_create_pull_request_comments( + secure_source_manager.BatchCreatePullRequestCommentsRequest(), + parent="parent_value", + requests=[ + secure_source_manager.CreatePullRequestCommentRequest( + parent="parent_value" + ) + ], + ) + + +def test_resolve_pull_request_comments_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.resolve_pull_request_comments + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.resolve_pull_request_comments + ] = mock_rpc + + request = {} + client.resolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.resolve_pull_request_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_resolve_pull_request_comments_rest_required_fields( + request_type=secure_source_manager.ResolvePullRequestCommentsRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["names"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).resolve_pull_request_comments._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + jsonified_request["names"] = "names_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).resolve_pull_request_comments._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "names" in jsonified_request + assert jsonified_request["names"] == "names_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.resolve_pull_request_comments(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_resolve_pull_request_comments_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.resolve_pull_request_comments._get_unset_required_fields( + {} + ) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "names", + ) + ) + ) + + +def test_resolve_pull_request_comments_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + names=["names_value"], + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.resolve_pull_request_comments(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*/pullRequests/*}/pullRequestComments:resolve" + % client.transport._host, + args[1], + ) + + +def test_resolve_pull_request_comments_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.resolve_pull_request_comments( + secure_source_manager.ResolvePullRequestCommentsRequest(), + parent="parent_value", + names=["names_value"], + ) + + +def test_unresolve_pull_request_comments_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.unresolve_pull_request_comments + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.unresolve_pull_request_comments + ] = mock_rpc + + request = {} + client.unresolve_pull_request_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.unresolve_pull_request_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_unresolve_pull_request_comments_rest_required_fields( + request_type=secure_source_manager.UnresolvePullRequestCommentsRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["names"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).unresolve_pull_request_comments._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + jsonified_request["names"] = "names_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).unresolve_pull_request_comments._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "names" in jsonified_request + assert jsonified_request["names"] == "names_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.unresolve_pull_request_comments(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_unresolve_pull_request_comments_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.unresolve_pull_request_comments._get_unset_required_fields( + {} + ) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "names", + ) + ) + ) + + +def test_unresolve_pull_request_comments_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + names=["names_value"], + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.unresolve_pull_request_comments(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*/pullRequests/*}/pullRequestComments:unresolve" + % client.transport._host, + args[1], + ) + + +def test_unresolve_pull_request_comments_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.unresolve_pull_request_comments( + secure_source_manager.UnresolvePullRequestCommentsRequest(), + parent="parent_value", + names=["names_value"], + ) + + +def test_create_issue_comment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_issue_comment in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_issue_comment + ] = mock_rpc + + request = {} + client.create_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_issue_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_issue_comment_rest_required_fields( + request_type=secure_source_manager.CreateIssueCommentRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_issue_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_issue_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_issue_comment(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_issue_comment_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_issue_comment._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "issueComment", + ) + ) + ) + + +def test_create_issue_comment_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + issue_comment=secure_source_manager.IssueComment(name="name_value"), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_issue_comment(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*/issues/*}/issueComments" + % client.transport._host, + args[1], + ) + + +def test_create_issue_comment_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_issue_comment( + secure_source_manager.CreateIssueCommentRequest(), + parent="parent_value", + issue_comment=secure_source_manager.IssueComment(name="name_value"), + ) + + +def test_get_issue_comment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_issue_comment in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_issue_comment + ] = mock_rpc + + request = {} + client.get_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_issue_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_issue_comment_rest_required_fields( + request_type=secure_source_manager.GetIssueCommentRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_issue_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_issue_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.IssueComment() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.IssueComment.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_issue_comment(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_issue_comment_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_issue_comment._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_issue_comment_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.IssueComment() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4/issueComments/sample5" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.IssueComment.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_issue_comment(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/issues/*/issueComments/*}" + % client.transport._host, + args[1], + ) + + +def test_get_issue_comment_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_issue_comment( + secure_source_manager.GetIssueCommentRequest(), + name="name_value", + ) + + +def test_list_issue_comments_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_issue_comments in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_issue_comments + ] = mock_rpc + + request = {} + client.list_issue_comments(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_issue_comments(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_issue_comments_rest_required_fields( + request_type=secure_source_manager.ListIssueCommentsRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_issue_comments._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_issue_comments._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListIssueCommentsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListIssueCommentsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_issue_comments(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_issue_comments_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_issue_comments._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_issue_comments_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListIssueCommentsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.ListIssueCommentsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_issue_comments(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/repositories/*/issues/*}/issueComments" + % client.transport._host, + args[1], + ) + + +def test_list_issue_comments_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issue_comments( + secure_source_manager.ListIssueCommentsRequest(), + parent="parent_value", + ) + + +def test_list_issue_comments_rest_pager(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + ], + next_page_token="abc", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[], + next_page_token="def", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + ], + next_page_token="ghi", + ), + secure_source_manager.ListIssueCommentsResponse( + issue_comments=[ + secure_source_manager.IssueComment(), + secure_source_manager.IssueComment(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + secure_source_manager.ListIssueCommentsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + + pager = client.list_issue_comments(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, secure_source_manager.IssueComment) for i in results) + + pages = list(client.list_issue_comments(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_update_issue_comment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_issue_comment in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_issue_comment + ] = mock_rpc + + request = {} + client.update_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_issue_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_issue_comment_rest_required_fields( + request_type=secure_source_manager.UpdateIssueCommentRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_issue_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_issue_comment._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_issue_comment(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_issue_comment_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_issue_comment._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask",)) & set(("issueComment",))) + + +def test_update_issue_comment_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "issue_comment": { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4/issueComments/sample5" + } + } + + # get truthy value for each flattened field + mock_args = dict( + issue_comment=secure_source_manager.IssueComment(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_issue_comment(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{issue_comment.name=projects/*/locations/*/repositories/*/issues/*/issueComments/*}" + % client.transport._host, + args[1], + ) + + +def test_update_issue_comment_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue_comment( + secure_source_manager.UpdateIssueCommentRequest(), + issue_comment=secure_source_manager.IssueComment(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_issue_comment_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_issue_comment in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_issue_comment + ] = mock_rpc + + request = {} + client.delete_issue_comment(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_issue_comment(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_issue_comment_rest_required_fields( + request_type=secure_source_manager.DeleteIssueCommentRequest, +): + transport_class = transports.SecureSourceManagerRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_issue_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_issue_comment._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_issue_comment(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_issue_comment_rest_unset_required_fields(): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_issue_comment._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_issue_comment_rest_flattened(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4/issueComments/sample5" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_issue_comment(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/repositories/*/issues/*/issueComments/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_issue_comment_rest_flattened_error(transport: str = "rest"): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_issue_comment( + secure_source_manager.DeleteIssueCommentRequest(), + name="name_value", + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.SecureSourceManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.SecureSourceManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = SecureSourceManagerClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.SecureSourceManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SecureSourceManagerClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SecureSourceManagerClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.SecureSourceManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = SecureSourceManagerClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.SecureSourceManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = SecureSourceManagerClient(transport=transport) + assert client.transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.SecureSourceManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.SecureSourceManagerGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.SecureSourceManagerGrpcTransport, + transports.SecureSourceManagerGrpcAsyncIOTransport, + transports.SecureSourceManagerRestTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +def test_transport_kind_grpc(): + transport = SecureSourceManagerClient.get_transport_class("grpc")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "grpc" + + +def test_initialize_client_w_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_instances_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_instances), "__call__") as call: + call.return_value = secure_source_manager.ListInstancesResponse() + client.list_instances(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListInstancesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_instance_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_instance), "__call__") as call: + call.return_value = secure_source_manager.Instance() + client.get_instance(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetInstanceRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_instance_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_instance), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_instance(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateInstanceRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_instance_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_instance), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_instance(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteInstanceRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_repositories_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_repositories), "__call__" + ) as call: + call.return_value = secure_source_manager.ListRepositoriesResponse() + client.list_repositories(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListRepositoriesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_repository_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_repository), "__call__") as call: + call.return_value = secure_source_manager.Repository() + client.get_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetRepositoryRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_repository_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_repository), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateRepositoryRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_repository_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_repository), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateRepositoryRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_repository_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_repository), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteRepositoryRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_hooks_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_hooks), "__call__") as call: + call.return_value = secure_source_manager.ListHooksResponse() + client.list_hooks(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListHooksRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_hook_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_hook), "__call__") as call: + call.return_value = secure_source_manager.Hook() + client.get_hook(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetHookRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_hook_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_hook), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_hook(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateHookRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_hook_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_hook), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_hook(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateHookRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_hook_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_hook), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_hook(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteHookRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_iam_policy_repo_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_iam_policy_repo), "__call__" + ) as call: + call.return_value = policy_pb2.Policy() + client.get_iam_policy_repo(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.GetIamPolicyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_set_iam_policy_repo_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.set_iam_policy_repo), "__call__" + ) as call: + call.return_value = policy_pb2.Policy() + client.set_iam_policy_repo(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.SetIamPolicyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_test_iam_permissions_repo_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions_repo), "__call__" + ) as call: + call.return_value = iam_policy_pb2.TestIamPermissionsResponse() + client.test_iam_permissions_repo(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.TestIamPermissionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_branch_rule_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_branch_rule), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_branch_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateBranchRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_branch_rules_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), "__call__" + ) as call: + call.return_value = secure_source_manager.ListBranchRulesResponse() + client.list_branch_rules(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListBranchRulesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_branch_rule_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + call.return_value = secure_source_manager.BranchRule() + client.get_branch_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetBranchRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_branch_rule_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_branch_rule), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_branch_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateBranchRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_branch_rule_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_branch_rule), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_branch_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteBranchRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_pull_request_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreatePullRequestRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_pull_request_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_pull_request), "__call__") as call: + call.return_value = secure_source_manager.PullRequest() + client.get_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetPullRequestRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_pull_requests_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), "__call__" + ) as call: + call.return_value = secure_source_manager.ListPullRequestsResponse() + client.list_pull_requests(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListPullRequestsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_pull_request_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdatePullRequestRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_merge_pull_request_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.merge_pull_request), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.merge_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.MergePullRequestRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_open_pull_request_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.open_pull_request), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.open_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.OpenPullRequestRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_close_pull_request_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.close_pull_request), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.close_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ClosePullRequestRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_pull_request_file_diffs_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), "__call__" + ) as call: + call.return_value = secure_source_manager.ListPullRequestFileDiffsResponse() + client.list_pull_request_file_diffs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListPullRequestFileDiffsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_fetch_tree_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.fetch_tree), "__call__") as call: + call.return_value = secure_source_manager.FetchTreeResponse() + client.fetch_tree(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.FetchTreeRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_fetch_blob_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.fetch_blob), "__call__") as call: + call.return_value = secure_source_manager.FetchBlobResponse() + client.fetch_blob(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.FetchBlobRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_issue_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_issue), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_issue_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + call.return_value = secure_source_manager.Issue() + client.get_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_issues_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + call.return_value = secure_source_manager.ListIssuesResponse() + client.list_issues(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListIssuesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_issue_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_issue_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_open_issue_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.open_issue), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.open_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.OpenIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_close_issue_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.close_issue), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.close_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CloseIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_pull_request_comment_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_pull_request_comment), "__call__" + ) as call: + call.return_value = secure_source_manager.PullRequestComment() + client.get_pull_request_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetPullRequestCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_pull_request_comments_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), "__call__" + ) as call: + call.return_value = secure_source_manager.ListPullRequestCommentsResponse() + client.list_pull_request_comments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListPullRequestCommentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_pull_request_comment_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request_comment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_pull_request_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreatePullRequestCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_pull_request_comment_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request_comment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_pull_request_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdatePullRequestCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_pull_request_comment_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_pull_request_comment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_pull_request_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeletePullRequestCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_batch_create_pull_request_comments_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_pull_request_comments), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.batch_create_pull_request_comments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.BatchCreatePullRequestCommentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_resolve_pull_request_comments_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.resolve_pull_request_comments), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.resolve_pull_request_comments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ResolvePullRequestCommentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_unresolve_pull_request_comments_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.unresolve_pull_request_comments), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.unresolve_pull_request_comments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UnresolvePullRequestCommentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_issue_comment_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_comment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_issue_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateIssueCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_issue_comment_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_comment), "__call__" + ) as call: + call.return_value = secure_source_manager.IssueComment() + client.get_issue_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetIssueCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_issue_comments_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), "__call__" + ) as call: + call.return_value = secure_source_manager.ListIssueCommentsResponse() + client.list_issue_comments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListIssueCommentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_issue_comment_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_comment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_issue_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateIssueCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_issue_comment_empty_call_grpc(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_comment), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_issue_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteIssueCommentRequest() + + assert args[0] == request_msg + + +def test_transport_kind_grpc_asyncio(): + transport = SecureSourceManagerAsyncClient.get_transport_class("grpc_asyncio")( + credentials=async_anonymous_credentials() + ) + assert transport.kind == "grpc_asyncio" + + +def test_initialize_client_w_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), transport="grpc_asyncio" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_instances_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_instances), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListInstancesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_instances(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListInstancesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_instance_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_instance), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.Instance( + name="name_value", + state=secure_source_manager.Instance.State.CREATING, + state_note=secure_source_manager.Instance.StateNote.PAUSED_CMEK_UNAVAILABLE, + kms_key="kms_key_value", + ) + ) + await client.get_instance(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetInstanceRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_instance_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_instance), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_instance(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateInstanceRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_instance_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_instance), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_instance(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteInstanceRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_repositories_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_repositories), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListRepositoriesResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_repositories(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListRepositoriesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_repository_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_repository), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.Repository( + name="name_value", + description="description_value", + instance="instance_value", + uid="uid_value", + etag="etag_value", + ) + ) + await client.get_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetRepositoryRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_repository_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_repository), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateRepositoryRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_repository_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_repository), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateRepositoryRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_repository_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_repository), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteRepositoryRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_hooks_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_hooks), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListHooksResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_hooks(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListHooksRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_hook_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_hook), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.Hook( + name="name_value", + target_uri="target_uri_value", + disabled=True, + events=[secure_source_manager.Hook.HookEventType.PUSH], + uid="uid_value", + sensitive_query_string="sensitive_query_string_value", + ) + ) + await client.get_hook(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetHookRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_hook_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_hook), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_hook(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateHookRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_hook_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_hook), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_hook(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateHookRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_hook_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_hook), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_hook(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteHookRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_iam_policy_repo_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_iam_policy_repo), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) + ) + await client.get_iam_policy_repo(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.GetIamPolicyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_set_iam_policy_repo_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.set_iam_policy_repo), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) + ) + await client.set_iam_policy_repo(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.SetIamPolicyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_test_iam_permissions_repo_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions_repo), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + iam_policy_pb2.TestIamPermissionsResponse( + permissions=["permissions_value"], + ) + ) + await client.test_iam_permissions_repo(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.TestIamPermissionsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_branch_rule_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_branch_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateBranchRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_branch_rules_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListBranchRulesResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_branch_rules(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListBranchRulesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_branch_rule_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.BranchRule( + name="name_value", + uid="uid_value", + etag="etag_value", + include_pattern="include_pattern_value", + disabled=True, + require_pull_request=True, + minimum_reviews_count=2280, + minimum_approvals_count=2491, + require_comments_resolved=True, + allow_stale_reviews=True, + require_linear_history=True, + ) + ) + await client.get_branch_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetBranchRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_branch_rule_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_branch_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateBranchRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_branch_rule_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_branch_rule), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_branch_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteBranchRuleRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_pull_request_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreatePullRequestRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_pull_request_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_pull_request), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.PullRequest( + name="name_value", + title="title_value", + body="body_value", + state=secure_source_manager.PullRequest.State.OPEN, + ) + ) + await client.get_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetPullRequestRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_pull_requests_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListPullRequestsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_pull_requests(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListPullRequestsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_pull_request_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdatePullRequestRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_merge_pull_request_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.merge_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.merge_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.MergePullRequestRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_open_pull_request_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.open_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.open_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.OpenPullRequestRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_close_pull_request_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.close_pull_request), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.close_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ClosePullRequestRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_pull_request_file_diffs_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListPullRequestFileDiffsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_pull_request_file_diffs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListPullRequestFileDiffsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_fetch_tree_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.fetch_tree), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.FetchTreeResponse( + next_page_token="next_page_token_value", + ) + ) + await client.fetch_tree(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.FetchTreeRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_fetch_blob_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.fetch_blob), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.FetchBlobResponse( + sha="sha_value", + content="content_value", + ) + ) + await client.fetch_blob(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.FetchBlobRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_issue_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_issue_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.Issue( + name="name_value", + title="title_value", + body="body_value", + state=secure_source_manager.Issue.State.OPEN, + etag="etag_value", + ) + ) + await client.get_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_issues_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListIssuesResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_issues(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListIssuesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_issue_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_issue_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_open_issue_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.open_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.open_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.OpenIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_close_issue_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.close_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.close_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CloseIssueRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_pull_request_comment_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.PullRequestComment( + name="name_value", + ) + ) + await client.get_pull_request_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetPullRequestCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_pull_request_comments_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListPullRequestCommentsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_pull_request_comments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListPullRequestCommentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_pull_request_comment_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_pull_request_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreatePullRequestCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_pull_request_comment_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_pull_request_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdatePullRequestCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_pull_request_comment_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_pull_request_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_pull_request_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeletePullRequestCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_batch_create_pull_request_comments_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.batch_create_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.batch_create_pull_request_comments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.BatchCreatePullRequestCommentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_resolve_pull_request_comments_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.resolve_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.resolve_pull_request_comments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ResolvePullRequestCommentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_unresolve_pull_request_comments_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.unresolve_pull_request_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.unresolve_pull_request_comments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UnresolvePullRequestCommentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_issue_comment_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_issue_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateIssueCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_issue_comment_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.IssueComment( + name="name_value", + body="body_value", + ) + ) + await client.get_issue_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetIssueCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_issue_comments_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_comments), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + secure_source_manager.ListIssueCommentsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_issue_comments(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListIssueCommentsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_issue_comment_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_issue_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateIssueCommentRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_issue_comment_empty_call_grpc_asyncio(): + client = SecureSourceManagerAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_comment), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_issue_comment(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteIssueCommentRequest() + + assert args[0] == request_msg + + +def test_transport_kind_rest(): + transport = SecureSourceManagerClient.get_transport_class("rest")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "rest" + + +def test_list_instances_rest_bad_request( + request_type=secure_source_manager.ListInstancesRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_instances(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListInstancesRequest, + dict, + ], +) +def test_list_instances_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListInstancesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListInstancesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_instances(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListInstancesPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_instances_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_list_instances" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_list_instances_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_list_instances" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.ListInstancesRequest.pb( + secure_source_manager.ListInstancesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.ListInstancesResponse.to_json( + secure_source_manager.ListInstancesResponse() + ) + req.return_value.content = return_value + + request = secure_source_manager.ListInstancesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.ListInstancesResponse() + post_with_metadata.return_value = ( + secure_source_manager.ListInstancesResponse(), + metadata, + ) + + client.list_instances( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_instance_rest_bad_request( + request_type=secure_source_manager.GetInstanceRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/instances/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_instance(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetInstanceRequest, + dict, + ], +) +def test_get_instance_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/instances/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.Instance( + name="name_value", + state=secure_source_manager.Instance.State.CREATING, + state_note=secure_source_manager.Instance.StateNote.PAUSED_CMEK_UNAVAILABLE, + kms_key="kms_key_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.Instance.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_instance(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.Instance) + assert response.name == "name_value" + assert response.state == secure_source_manager.Instance.State.CREATING + assert ( + response.state_note + == secure_source_manager.Instance.StateNote.PAUSED_CMEK_UNAVAILABLE + ) + assert response.kms_key == "kms_key_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_instance_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_get_instance" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_get_instance_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_get_instance" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.GetInstanceRequest.pb( + secure_source_manager.GetInstanceRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.Instance.to_json( + secure_source_manager.Instance() + ) + req.return_value.content = return_value + + request = secure_source_manager.GetInstanceRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.Instance() + post_with_metadata.return_value = secure_source_manager.Instance(), metadata + + client.get_instance( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_instance_rest_bad_request( + request_type=secure_source_manager.CreateInstanceRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_instance(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CreateInstanceRequest, + dict, + ], +) +def test_create_instance_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["instance"] = { + "name": "name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "labels": {}, + "private_config": { + "is_private": True, + "ca_pool": "ca_pool_value", + "http_service_attachment": "http_service_attachment_value", + "ssh_service_attachment": "ssh_service_attachment_value", + "psc_allowed_projects": [ + "psc_allowed_projects_value1", + "psc_allowed_projects_value2", + ], + }, + "state": 1, + "state_note": 1, + "kms_key": "kms_key_value", + "host_config": { + "html": "html_value", + "api": "api_value", + "git_http": "git_http_value", + "git_ssh": "git_ssh_value", + }, + "workforce_identity_federation_config": {"enabled": True}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.CreateInstanceRequest.meta.fields["instance"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["instance"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["instance"][field])): + del request_init["instance"][field][i][subfield] + else: + del request_init["instance"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_instance(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_instance_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_create_instance" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_create_instance_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_create_instance" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.CreateInstanceRequest.pb( + secure_source_manager.CreateInstanceRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = secure_source_manager.CreateInstanceRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_instance( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_instance_rest_bad_request( + request_type=secure_source_manager.DeleteInstanceRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/instances/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_instance(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.DeleteInstanceRequest, + dict, + ], +) +def test_delete_instance_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/instances/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_instance(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_instance_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_delete_instance" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_delete_instance_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_delete_instance" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.DeleteInstanceRequest.pb( + secure_source_manager.DeleteInstanceRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = secure_source_manager.DeleteInstanceRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_instance( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_repositories_rest_bad_request( + request_type=secure_source_manager.ListRepositoriesRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_repositories(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListRepositoriesRequest, + dict, + ], +) +def test_list_repositories_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListRepositoriesResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListRepositoriesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_repositories(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListRepositoriesPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_repositories_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_list_repositories" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_list_repositories_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_list_repositories" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.ListRepositoriesRequest.pb( + secure_source_manager.ListRepositoriesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.ListRepositoriesResponse.to_json( + secure_source_manager.ListRepositoriesResponse() + ) + req.return_value.content = return_value + + request = secure_source_manager.ListRepositoriesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.ListRepositoriesResponse() + post_with_metadata.return_value = ( + secure_source_manager.ListRepositoriesResponse(), + metadata, + ) + + client.list_repositories( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_repository_rest_bad_request( + request_type=secure_source_manager.GetRepositoryRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_repository(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetRepositoryRequest, + dict, + ], +) +def test_get_repository_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.Repository( + name="name_value", + description="description_value", + instance="instance_value", + uid="uid_value", + etag="etag_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.Repository.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_repository(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.Repository) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.instance == "instance_value" + assert response.uid == "uid_value" + assert response.etag == "etag_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_repository_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_get_repository" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_get_repository_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_get_repository" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.GetRepositoryRequest.pb( + secure_source_manager.GetRepositoryRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.Repository.to_json( + secure_source_manager.Repository() + ) + req.return_value.content = return_value + + request = secure_source_manager.GetRepositoryRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.Repository() + post_with_metadata.return_value = secure_source_manager.Repository(), metadata + + client.get_repository( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_repository_rest_bad_request( + request_type=secure_source_manager.CreateRepositoryRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_repository(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CreateRepositoryRequest, + dict, + ], +) +def test_create_repository_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["repository"] = { + "name": "name_value", + "description": "description_value", + "instance": "instance_value", + "uid": "uid_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "etag": "etag_value", + "uris": { + "html": "html_value", + "git_https": "git_https_value", + "api": "api_value", + }, + "initial_config": { + "default_branch": "default_branch_value", + "gitignores": ["gitignores_value1", "gitignores_value2"], + "license_": "license__value", + "readme": "readme_value", + }, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.CreateRepositoryRequest.meta.fields["repository"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["repository"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["repository"][field])): + del request_init["repository"][field][i][subfield] + else: + del request_init["repository"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_repository(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_repository_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_create_repository" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_create_repository_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_create_repository" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.CreateRepositoryRequest.pb( + secure_source_manager.CreateRepositoryRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = secure_source_manager.CreateRepositoryRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_repository( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_repository_rest_bad_request( + request_type=secure_source_manager.UpdateRepositoryRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "repository": { + "name": "projects/sample1/locations/sample2/repositories/sample3" + } + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_repository(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.UpdateRepositoryRequest, + dict, + ], +) +def test_update_repository_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "repository": { + "name": "projects/sample1/locations/sample2/repositories/sample3" + } + } + request_init["repository"] = { + "name": "projects/sample1/locations/sample2/repositories/sample3", + "description": "description_value", + "instance": "instance_value", + "uid": "uid_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "etag": "etag_value", + "uris": { + "html": "html_value", + "git_https": "git_https_value", + "api": "api_value", + }, + "initial_config": { + "default_branch": "default_branch_value", + "gitignores": ["gitignores_value1", "gitignores_value2"], + "license_": "license__value", + "readme": "readme_value", + }, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.UpdateRepositoryRequest.meta.fields["repository"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["repository"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["repository"][field])): + del request_init["repository"][field][i][subfield] + else: + del request_init["repository"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_repository(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_repository_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_update_repository" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_update_repository_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_update_repository" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.UpdateRepositoryRequest.pb( + secure_source_manager.UpdateRepositoryRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = secure_source_manager.UpdateRepositoryRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_repository( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_repository_rest_bad_request( + request_type=secure_source_manager.DeleteRepositoryRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_repository(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.DeleteRepositoryRequest, + dict, + ], +) +def test_delete_repository_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_repository(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_repository_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_delete_repository" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_delete_repository_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_delete_repository" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.DeleteRepositoryRequest.pb( + secure_source_manager.DeleteRepositoryRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = secure_source_manager.DeleteRepositoryRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_repository( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_hooks_rest_bad_request( + request_type=secure_source_manager.ListHooksRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_hooks(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListHooksRequest, + dict, + ], +) +def test_list_hooks_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListHooksResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListHooksResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_hooks(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListHooksPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_hooks_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_list_hooks" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_list_hooks_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_list_hooks" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.ListHooksRequest.pb( + secure_source_manager.ListHooksRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.ListHooksResponse.to_json( + secure_source_manager.ListHooksResponse() + ) + req.return_value.content = return_value + + request = secure_source_manager.ListHooksRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.ListHooksResponse() + post_with_metadata.return_value = ( + secure_source_manager.ListHooksResponse(), + metadata, + ) + + client.list_hooks( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_hook_rest_bad_request(request_type=secure_source_manager.GetHookRequest): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/hooks/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_hook(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetHookRequest, + dict, + ], +) +def test_get_hook_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/hooks/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.Hook( + name="name_value", + target_uri="target_uri_value", + disabled=True, + events=[secure_source_manager.Hook.HookEventType.PUSH], + uid="uid_value", + sensitive_query_string="sensitive_query_string_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.Hook.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_hook(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.Hook) + assert response.name == "name_value" + assert response.target_uri == "target_uri_value" + assert response.disabled is True + assert response.events == [secure_source_manager.Hook.HookEventType.PUSH] + assert response.uid == "uid_value" + assert response.sensitive_query_string == "sensitive_query_string_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_hook_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_get_hook" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_get_hook_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_get_hook" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.GetHookRequest.pb( + secure_source_manager.GetHookRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.Hook.to_json(secure_source_manager.Hook()) + req.return_value.content = return_value + + request = secure_source_manager.GetHookRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.Hook() + post_with_metadata.return_value = secure_source_manager.Hook(), metadata + + client.get_hook( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_hook_rest_bad_request( + request_type=secure_source_manager.CreateHookRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_hook(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CreateHookRequest, + dict, + ], +) +def test_create_hook_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init["hook"] = { + "name": "name_value", + "target_uri": "target_uri_value", + "disabled": True, + "events": [1], + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "uid": "uid_value", + "push_option": {"branch_filter": "branch_filter_value"}, + "sensitive_query_string": "sensitive_query_string_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.CreateHookRequest.meta.fields["hook"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["hook"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["hook"][field])): + del request_init["hook"][field][i][subfield] + else: + del request_init["hook"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_hook(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_hook_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_create_hook" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_create_hook_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_create_hook" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.CreateHookRequest.pb( + secure_source_manager.CreateHookRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = secure_source_manager.CreateHookRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_hook( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_hook_rest_bad_request( + request_type=secure_source_manager.UpdateHookRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "hook": { + "name": "projects/sample1/locations/sample2/repositories/sample3/hooks/sample4" + } + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_hook(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.UpdateHookRequest, + dict, + ], +) +def test_update_hook_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "hook": { + "name": "projects/sample1/locations/sample2/repositories/sample3/hooks/sample4" + } + } + request_init["hook"] = { + "name": "projects/sample1/locations/sample2/repositories/sample3/hooks/sample4", + "target_uri": "target_uri_value", + "disabled": True, + "events": [1], + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "uid": "uid_value", + "push_option": {"branch_filter": "branch_filter_value"}, + "sensitive_query_string": "sensitive_query_string_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.UpdateHookRequest.meta.fields["hook"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["hook"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["hook"][field])): + del request_init["hook"][field][i][subfield] + else: + del request_init["hook"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_hook(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_hook_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_update_hook" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_update_hook_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_update_hook" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.UpdateHookRequest.pb( + secure_source_manager.UpdateHookRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = secure_source_manager.UpdateHookRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_hook( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_hook_rest_bad_request( + request_type=secure_source_manager.DeleteHookRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/hooks/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_hook(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.DeleteHookRequest, + dict, + ], +) +def test_delete_hook_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/hooks/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_hook(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_hook_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_delete_hook" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_delete_hook_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_delete_hook" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.DeleteHookRequest.pb( + secure_source_manager.DeleteHookRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = secure_source_manager.DeleteHookRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_hook( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_iam_policy_repo_rest_bad_request( + request_type=iam_policy_pb2.GetIamPolicyRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "resource": "projects/sample1/locations/sample2/repositories/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_iam_policy_repo(request) + + +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.GetIamPolicyRequest, + dict, + ], +) +def test_get_iam_policy_repo_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "resource": "projects/sample1/locations/sample2/repositories/sample3" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_iam_policy_repo(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, policy_pb2.Policy) + assert response.version == 774 + assert response.etag == b"etag_blob" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_iam_policy_repo_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_get_iam_policy_repo" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_get_iam_policy_repo_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_get_iam_policy_repo" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = iam_policy_pb2.GetIamPolicyRequest() + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(policy_pb2.Policy()) + req.return_value.content = return_value + + request = iam_policy_pb2.GetIamPolicyRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = policy_pb2.Policy() + post_with_metadata.return_value = policy_pb2.Policy(), metadata + + client.get_iam_policy_repo( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - client.get_repository(request) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 +def test_set_iam_policy_repo_rest_bad_request( + request_type=iam_policy_pb2.SetIamPolicyRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "resource": "projects/sample1/locations/sample2/repositories/sample3" + } + request = request_type(**request_init) + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.set_iam_policy_repo(request) -def test_get_repository_rest_required_fields( - request_type=secure_source_manager.GetRepositoryRequest, -): - transport_class = transports.SecureSourceManagerRestTransport - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.SetIamPolicyRequest, + dict, + ], +) +def test_set_iam_policy_repo_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # send a request that will satisfy transcoding + request_init = { + "resource": "projects/sample1/locations/sample2/repositories/sample3" + } + request = request_type(**request_init) - # verify required fields with default values are now present + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) - jsonified_request["name"] = "name_value" + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.set_iam_policy_repo(request) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Establish that the response is the type that we expect. + assert isinstance(response, policy_pb2.Policy) + assert response.version == 774 + assert response.etag == b"etag_blob" - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_set_iam_policy_repo_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = secure_source_manager.Repository() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + client = SecureSourceManagerClient(transport=transport) - response_value = Response() - response_value.status_code = 200 + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_set_iam_policy_repo" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_set_iam_policy_repo_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_set_iam_policy_repo" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = iam_policy_pb2.SetIamPolicyRequest() + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Convert return value to protobuf type - return_value = secure_source_manager.Repository.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(policy_pb2.Policy()) + req.return_value.content = return_value - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + request = iam_policy_pb2.SetIamPolicyRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = policy_pb2.Policy() + post_with_metadata.return_value = policy_pb2.Policy(), metadata - response = client.get_repository(request) + client.set_iam_policy_repo( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_get_repository_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_test_iam_permissions_repo_rest_bad_request( + request_type=iam_policy_pb2.TestIamPermissionsRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "resource": "projects/sample1/locations/sample2/repositories/sample3" + } + request = request_type(**request_init) - unset_fields = transport.get_repository._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.test_iam_permissions_repo(request) -def test_get_repository_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.TestIamPermissionsRequest, + dict, + ], +) +def test_test_iam_permissions_repo_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "resource": "projects/sample1/locations/sample2/repositories/sample3" + } + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = secure_source_manager.Repository() - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3" - } - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + return_value = iam_policy_pb2.TestIamPermissionsResponse( + permissions=["permissions_value"], ) - mock_args.update(sample_request) # Wrap the value into a proper Response obj - response_value = Response() + response_value = mock.Mock() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = secure_source_manager.Repository.pb(return_value) json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") + response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.test_iam_permissions_repo(request) - client.get_repository(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*}" - % client.transport._host, - args[1], - ) - + # Establish that the response is the type that we expect. + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) + assert response.permissions == ["permissions_value"] -def test_get_repository_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_test_iam_permissions_repo_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_repository( - secure_source_manager.GetRepositoryRequest(), - name="name_value", - ) - + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_test_iam_permissions_repo" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_test_iam_permissions_repo_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_test_iam_permissions_repo" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = iam_policy_pb2.TestIamPermissionsRequest() + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } -def test_create_repository_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson( + iam_policy_pb2.TestIamPermissionsResponse() ) + req.return_value.content = return_value - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_repository in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + request = iam_policy_pb2.TestIamPermissionsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = iam_policy_pb2.TestIamPermissionsResponse() + post_with_metadata.return_value = ( + iam_policy_pb2.TestIamPermissionsResponse(), + metadata, ) - client._transport._wrapped_methods[ - client._transport.create_repository - ] = mock_rpc - - request = {} - client.create_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - client.create_repository(request) + client.test_iam_permissions_repo( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_create_repository_rest_required_fields( - request_type=secure_source_manager.CreateRepositoryRequest, +def test_create_branch_rule_rest_bad_request( + request_type=secure_source_manager.CreateBranchRuleRequest, ): - transport_class = transports.SecureSourceManagerRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["repository_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) - # verify fields with default values are dropped - assert "repositoryId" not in jsonified_request - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "repositoryId" in jsonified_request - assert jsonified_request["repositoryId"] == request_init["repository_id"] - - jsonified_request["parent"] = "parent_value" - jsonified_request["repositoryId"] = "repository_id_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_repository._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("repository_id",)) - jsonified_request.update(unset_fields) + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_branch_rule(request) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - assert "repositoryId" in jsonified_request - assert jsonified_request["repositoryId"] == "repository_id_value" +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CreateBranchRuleRequest, + dict, + ], +) +def test_create_branch_rule_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init["branch_rule"] = { + "name": "name_value", + "uid": "uid_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "annotations": {}, + "etag": "etag_value", + "include_pattern": "include_pattern_value", + "disabled": True, + "require_pull_request": True, + "minimum_reviews_count": 2280, + "minimum_approvals_count": 2491, + "require_comments_resolved": True, + "allow_stale_reviews": True, + "require_linear_history": True, + "required_status_checks": [{"context": "context_value"}], + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.CreateBranchRuleRequest.meta.fields[ + "branch_rule" + ] - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] - response = client.create_repository(request) + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - expected_params = [ - ( - "repositoryId", - "", - ), - ("$alt", "json;enum-encoding=int"), - ] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] -def test_create_repository_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) + subfields_not_in_runtime = [] - unset_fields = transport.create_repository._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(("repositoryId",)) - & set( - ( - "parent", - "repository", - "repositoryId", - ) - ) - ) + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["branch_rule"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) -def test_create_repository_rest_flattened(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["branch_rule"][field])): + del request_init["branch_rule"][field][i][subfield] + else: + del request_init["branch_rule"][field][subfield] + request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. return_value = operations_pb2.Operation(name="operations/spam") - # get arguments that satisfy an http rule for this method - sample_request = {"parent": "projects/sample1/locations/sample2"} - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - repository=secure_source_manager.Repository(name="name_value"), - repository_id="repository_id_value", - ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() + response_value = mock.Mock() response_value.status_code = 200 json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") + response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_branch_rule(request) - client.create_repository(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*}/repositories" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -def test_create_repository_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_branch_rule_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_repository( - secure_source_manager.CreateRepositoryRequest(), - parent="parent_value", - repository=secure_source_manager.Repository(name="name_value"), - repository_id="repository_id_value", - ) - - -def test_delete_repository_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_create_branch_rule" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_create_branch_rule_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_create_branch_rule" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.CreateBranchRuleRequest.pb( + secure_source_manager.CreateBranchRuleRequest() ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - # Ensure method has been cached - assert client._transport.delete_repository in client._transport._wrapped_methods + request = secure_source_manager.CreateBranchRuleRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + client.create_branch_rule( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - client._transport._wrapped_methods[ - client._transport.delete_repository - ] = mock_rpc - - request = {} - client.delete_repository(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_repository(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_repository_rest_required_fields( - request_type=secure_source_manager.DeleteRepositoryRequest, -): - transport_class = transports.SecureSourceManagerRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_repository._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = "name_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_repository._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("allow_missing",)) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" - - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "delete", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_repository(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_delete_repository_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_list_branch_rules_rest_bad_request( + request_type=secure_source_manager.ListBranchRulesRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) - unset_fields = transport.delete_repository._get_unset_required_fields({}) - assert set(unset_fields) == (set(("allowMissing",)) & set(("name",))) + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_branch_rules(request) -def test_delete_repository_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListBranchRulesRequest, + dict, + ], +) +def test_list_branch_rules_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3" - } - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + return_value = secure_source_manager.ListBranchRulesResponse( + next_page_token="next_page_token_value", ) - mock_args.update(sample_request) # Wrap the value into a proper Response obj - response_value = Response() + response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListBranchRulesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") + response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_branch_rules(request) - client.delete_repository(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*}" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListBranchRulesPager) + assert response.next_page_token == "next_page_token_value" -def test_delete_repository_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_branch_rules_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_repository( - secure_source_manager.DeleteRepositoryRequest(), - name="name_value", + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_list_branch_rules" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_list_branch_rules_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_list_branch_rules" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.ListBranchRulesRequest.pb( + secure_source_manager.ListBranchRulesRequest() ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - -def test_get_iam_policy_repo_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.ListBranchRulesResponse.to_json( + secure_source_manager.ListBranchRulesResponse() ) + req.return_value.content = return_value - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._transport.get_iam_policy_repo in client._transport._wrapped_methods + request = secure_source_manager.ListBranchRulesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.ListBranchRulesResponse() + post_with_metadata.return_value = ( + secure_source_manager.ListBranchRulesResponse(), + metadata, ) - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + client.list_branch_rules( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - client._transport._wrapped_methods[ - client._transport.get_iam_policy_repo - ] = mock_rpc - request = {} - client.get_iam_policy_repo(request) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - client.get_iam_policy_repo(request) +def test_get_branch_rule_rest_bad_request( + request_type=secure_source_manager.GetBranchRuleRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" + } + request = request_type(**request_init) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_branch_rule(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetBranchRuleRequest, + dict, + ], +) +def test_get_branch_rule_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.BranchRule( + name="name_value", + uid="uid_value", + etag="etag_value", + include_pattern="include_pattern_value", + disabled=True, + require_pull_request=True, + minimum_reviews_count=2280, + minimum_approvals_count=2491, + require_comments_resolved=True, + allow_stale_reviews=True, + require_linear_history=True, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.BranchRule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_branch_rule(request) + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.BranchRule) + assert response.name == "name_value" + assert response.uid == "uid_value" + assert response.etag == "etag_value" + assert response.include_pattern == "include_pattern_value" + assert response.disabled is True + assert response.require_pull_request is True + assert response.minimum_reviews_count == 2280 + assert response.minimum_approvals_count == 2491 + assert response.require_comments_resolved is True + assert response.allow_stale_reviews is True + assert response.require_linear_history is True -def test_get_iam_policy_repo_rest_required_fields( - request_type=iam_policy_pb2.GetIamPolicyRequest, -): - transport_class = transports.SecureSourceManagerRestTransport - request_init = {} - request_init["resource"] = "" - request = request_type(**request_init) - pb_request = request - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_branch_rule_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # verify fields with default values are dropped + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_get_branch_rule" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_get_branch_rule_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_get_branch_rule" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.GetBranchRuleRequest.pb( + secure_source_manager.GetBranchRuleRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_iam_policy_repo._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.BranchRule.to_json( + secure_source_manager.BranchRule() + ) + req.return_value.content = return_value - # verify required fields with default values are now present + request = secure_source_manager.GetBranchRuleRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.BranchRule() + post_with_metadata.return_value = secure_source_manager.BranchRule(), metadata - jsonified_request["resource"] = "resource_value" + client.get_branch_rule( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_iam_policy_repo._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("options",)) - jsonified_request.update(unset_fields) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - # verify required fields with non-default values are left alone - assert "resource" in jsonified_request - assert jsonified_request["resource"] == "resource_value" +def test_update_branch_rule_rest_bad_request( + request_type=secure_source_manager.UpdateBranchRuleRequest, +): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "branch_rule": { + "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" + } + } request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_branch_rule(request) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.UpdateBranchRuleRequest, + dict, + ], +) +def test_update_branch_rule_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) - response = client.get_iam_policy_repo(request) + # send a request that will satisfy transcoding + request_init = { + "branch_rule": { + "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" + } + } + request_init["branch_rule"] = { + "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4", + "uid": "uid_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "annotations": {}, + "etag": "etag_value", + "include_pattern": "include_pattern_value", + "disabled": True, + "require_pull_request": True, + "minimum_reviews_count": 2280, + "minimum_approvals_count": 2491, + "require_comments_resolved": True, + "allow_stale_reviews": True, + "require_linear_history": True, + "required_status_checks": [{"context": "context_value"}], + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.UpdateBranchRuleRequest.meta.fields[ + "branch_rule" + ] + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] -def test_get_iam_policy_repo_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - unset_fields = transport.get_iam_policy_repo._get_unset_required_fields({}) - assert set(unset_fields) == (set(("options",)) & set(("resource",))) + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] -def test_get_iam_policy_repo_rest_flattened(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) + subfields_not_in_runtime = [] - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy() + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["branch_rule"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value - # get arguments that satisfy an http rule for this method - sample_request = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" - } + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) - # get truthy value for each flattened field - mock_args = dict( - resource="resource_value", - ) - mock_args.update(sample_request) + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["branch_rule"][field])): + del request_init["branch_rule"][field][i][subfield] + else: + del request_init["branch_rule"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj - response_value = Response() + response_value = mock.Mock() response_value.status_code = 200 json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") + response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_branch_rule(request) - client.get_iam_policy_repo(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{resource=projects/*/locations/*/repositories/*}:getIamPolicy" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -def test_get_iam_policy_repo_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_branch_rule_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_iam_policy_repo( - iam_policy_pb2.GetIamPolicyRequest(), - resource="resource_value", - ) - - -def test_set_iam_policy_repo_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_update_branch_rule" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_update_branch_rule_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_update_branch_rule" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.UpdateBranchRuleRequest.pb( + secure_source_manager.UpdateBranchRuleRequest() ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - # Ensure method has been cached - assert ( - client._transport.set_iam_policy_repo in client._transport._wrapped_methods - ) + request = secure_source_manager.UpdateBranchRuleRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + client.update_branch_rule( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - client._transport._wrapped_methods[ - client._transport.set_iam_policy_repo - ] = mock_rpc - - request = {} - client.set_iam_policy_repo(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.set_iam_policy_repo(request) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_set_iam_policy_repo_rest_required_fields( - request_type=iam_policy_pb2.SetIamPolicyRequest, +def test_delete_branch_rule_rest_bad_request( + request_type=secure_source_manager.DeleteBranchRuleRequest, ): - transport_class = transports.SecureSourceManagerRestTransport - - request_init = {} - request_init["resource"] = "" - request = request_type(**request_init) - pb_request = request - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) - ) - - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).set_iam_policy_repo._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["resource"] = "resource_value" - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).set_iam_policy_repo._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "resource" in jsonified_request - assert jsonified_request["resource"] == "resource_value" - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" + } request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.set_iam_policy_repo(request) - - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params - - -def test_set_iam_policy_repo_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) - - unset_fields = transport.set_iam_policy_repo._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "resource", - "policy", - ) - ) - ) + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_branch_rule(request) -def test_set_iam_policy_repo_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.DeleteBranchRuleRequest, + dict, + ], +) +def test_delete_branch_rule_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" + } + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy() - - # get arguments that satisfy an http rule for this method - sample_request = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" - } - - # get truthy value for each flattened field - mock_args = dict( - resource="resource_value", - ) - mock_args.update(sample_request) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj - response_value = Response() + response_value = mock.Mock() response_value.status_code = 200 json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") + response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_branch_rule(request) - client.set_iam_policy_repo(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{resource=projects/*/locations/*/repositories/*}:setIamPolicy" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -def test_set_iam_policy_repo_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_branch_rule_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.set_iam_policy_repo( - iam_policy_pb2.SetIamPolicyRequest(), - resource="resource_value", - ) - - -def test_test_iam_permissions_repo_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_delete_branch_rule" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_delete_branch_rule_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_delete_branch_rule" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.DeleteBranchRuleRequest.pb( + secure_source_manager.DeleteBranchRuleRequest() ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - # Ensure method has been cached - assert ( - client._transport.test_iam_permissions_repo - in client._transport._wrapped_methods - ) + request = secure_source_manager.DeleteBranchRuleRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_branch_rule( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - client._transport._wrapped_methods[ - client._transport.test_iam_permissions_repo - ] = mock_rpc - - request = {} - client.test_iam_permissions_repo(request) - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - client.test_iam_permissions_repo(request) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 +def test_create_pull_request_rest_bad_request( + request_type=secure_source_manager.CreatePullRequestRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_pull_request(request) -def test_test_iam_permissions_repo_rest_required_fields( - request_type=iam_policy_pb2.TestIamPermissionsRequest, -): - transport_class = transports.SecureSourceManagerRestTransport - request_init = {} - request_init["resource"] = "" - request_init["permissions"] = "" - request = request_type(**request_init) - pb_request = request - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CreatePullRequestRequest, + dict, + ], +) +def test_create_pull_request_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # verify fields with default values are dropped + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init["pull_request"] = { + "name": "name_value", + "title": "title_value", + "body": "body_value", + "base": {"ref": "ref_value", "sha": "sha_value"}, + "head": {}, + "state": 1, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "close_time": {}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).test_iam_permissions_repo._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.CreatePullRequestRequest.meta.fields[ + "pull_request" + ] - # verify required fields with default values are now present + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] - jsonified_request["resource"] = "resource_value" - jsonified_request["permissions"] = "permissions_value" + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).test_iam_permissions_repo._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields - # verify required fields with non-default values are left alone - assert "resource" in jsonified_request - assert jsonified_request["resource"] == "resource_value" - assert "permissions" in jsonified_request - assert jsonified_request["permissions"] == "permissions_value" + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type(**request_init) + subfields_not_in_runtime = [] - # Designate an appropriate value for the returned response. - return_value = iam_policy_pb2.TestIamPermissionsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["pull_request"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value - response_value = Response() - response_value.status_code = 200 + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) - json_return_value = json_format.MessageToJson(return_value) + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["pull_request"][field])): + del request_init["pull_request"][field][i][subfield] + else: + del request_init["pull_request"][field][subfield] + request = request_type(**request_init) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - response = client.test_iam_permissions_repo(request) + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_pull_request(request) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -def test_test_iam_permissions_repo_rest_unset_required_fields(): +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_pull_request_rest_interceptors(null_interceptor): transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - unset_fields = transport.test_iam_permissions_repo._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(()) - & set( - ( - "resource", - "permissions", - ) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_create_pull_request" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_create_pull_request_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_create_pull_request" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.CreatePullRequestRequest.pb( + secure_source_manager.CreatePullRequestRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = secure_source_manager.CreatePullRequestRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_pull_request( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_pull_request_rest_bad_request( + request_type=secure_source_manager.GetPullRequestRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_pull_request(request) -def test_test_iam_permissions_repo_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetPullRequestRequest, + dict, + ], +) +def test_get_pull_request_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = iam_policy_pb2.TestIamPermissionsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" - } - - # get truthy value for each flattened field - mock_args = dict( - resource="resource_value", + return_value = secure_source_manager.PullRequest( + name="name_value", + title="title_value", + body="body_value", + state=secure_source_manager.PullRequest.State.OPEN, ) - mock_args.update(sample_request) # Wrap the value into a proper Response obj - response_value = Response() + response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.PullRequest.pb(return_value) json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") + response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_pull_request(request) - client.test_iam_permissions_repo(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{resource=projects/*/locations/*/repositories/*}:testIamPermissions" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.PullRequest) + assert response.name == "name_value" + assert response.title == "title_value" + assert response.body == "body_value" + assert response.state == secure_source_manager.PullRequest.State.OPEN -def test_test_iam_permissions_repo_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_pull_request_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.test_iam_permissions_repo( - iam_policy_pb2.TestIamPermissionsRequest(), - resource="resource_value", + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_get_pull_request" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_get_pull_request_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_get_pull_request" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.GetPullRequestRequest.pb( + secure_source_manager.GetPullRequestRequest() ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - -def test_create_branch_rule_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.PullRequest.to_json( + secure_source_manager.PullRequest() ) + req.return_value.content = return_value - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + request = secure_source_manager.GetPullRequestRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.PullRequest() + post_with_metadata.return_value = secure_source_manager.PullRequest(), metadata - # Ensure method has been cached - assert ( - client._transport.create_branch_rule in client._transport._wrapped_methods + client.get_pull_request( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.create_branch_rule - ] = mock_rpc + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - request = {} - client.create_branch_rule(request) - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 +def test_list_pull_requests_rest_bad_request( + request_type=secure_source_manager.ListPullRequestsRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_pull_requests(request) + + +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListPullRequestsRequest, + dict, + ], +) +def test_list_pull_requests_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListPullRequestsResponse( + next_page_token="next_page_token_value", + ) - client.create_branch_rule(request) + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + # Convert return value to protobuf type + return_value = secure_source_manager.ListPullRequestsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_pull_requests(request) + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPullRequestsPager) + assert response.next_page_token == "next_page_token_value" -def test_create_branch_rule_rest_required_fields( - request_type=secure_source_manager.CreateBranchRuleRequest, -): - transport_class = transports.SecureSourceManagerRestTransport - request_init = {} - request_init["parent"] = "" - request_init["branch_rule_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_pull_requests_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # verify fields with default values are dropped - assert "branchRuleId" not in jsonified_request + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_list_pull_requests" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_list_pull_requests_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_list_pull_requests" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.ListPullRequestsRequest.pb( + secure_source_manager.ListPullRequestsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_branch_rule._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.ListPullRequestsResponse.to_json( + secure_source_manager.ListPullRequestsResponse() + ) + req.return_value.content = return_value - # verify required fields with default values are now present - assert "branchRuleId" in jsonified_request - assert jsonified_request["branchRuleId"] == request_init["branch_rule_id"] + request = secure_source_manager.ListPullRequestsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.ListPullRequestsResponse() + post_with_metadata.return_value = ( + secure_source_manager.ListPullRequestsResponse(), + metadata, + ) - jsonified_request["parent"] = "parent_value" - jsonified_request["branchRuleId"] = "branch_rule_id_value" + client.list_pull_requests( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).create_branch_rule._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("branch_rule_id",)) - jsonified_request.update(unset_fields) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - assert "branchRuleId" in jsonified_request - assert jsonified_request["branchRuleId"] == "branch_rule_id_value" +def test_update_pull_request_rest_bad_request( + request_type=secure_source_manager.UpdatePullRequestRequest, +): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "pull_request": { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + } request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "post", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_pull_request(request) - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.UpdatePullRequestRequest, + dict, + ], +) +def test_update_pull_request_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) - response = client.create_branch_rule(request) + # send a request that will satisfy transcoding + request_init = { + "pull_request": { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + } + request_init["pull_request"] = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4", + "title": "title_value", + "body": "body_value", + "base": {"ref": "ref_value", "sha": "sha_value"}, + "head": {}, + "state": 1, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "close_time": {}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 - expected_params = [ - ( - "branchRuleId", - "", - ), - ("$alt", "json;enum-encoding=int"), - ] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.UpdatePullRequestRequest.meta.fields[ + "pull_request" + ] + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] -def test_create_branch_rule_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - unset_fields = transport.create_branch_rule._get_unset_required_fields({}) - assert set(unset_fields) == ( - set(("branchRuleId",)) - & set( - ( - "parent", - "branchRule", - "branchRuleId", - ) - ) - ) + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] -def test_create_branch_rule_rest_flattened(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["pull_request"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["pull_request"][field])): + del request_init["pull_request"][field][i][subfield] + else: + del request_init["pull_request"][field][subfield] + request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. return_value = operations_pb2.Operation(name="operations/spam") - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - branch_rule=secure_source_manager.BranchRule(name="name_value"), - branch_rule_id="branch_rule_id_value", - ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() + response_value = mock.Mock() response_value.status_code = 200 json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") + response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_pull_request(request) - client.create_branch_rule(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/repositories/*}/branchRules" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -def test_create_branch_rule_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_pull_request_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_branch_rule( - secure_source_manager.CreateBranchRuleRequest(), - parent="parent_value", - branch_rule=secure_source_manager.BranchRule(name="name_value"), - branch_rule_id="branch_rule_id_value", - ) - - -def test_list_branch_rules_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_update_pull_request" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_update_pull_request_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_update_pull_request" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.UpdatePullRequestRequest.pb( + secure_source_manager.UpdatePullRequestRequest() ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - # Ensure method has been cached - assert client._transport.list_branch_rules in client._transport._wrapped_methods + request = secure_source_manager.UpdatePullRequestRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + client.update_pull_request( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - client._transport._wrapped_methods[ - client._transport.list_branch_rules - ] = mock_rpc - request = {} - client.list_branch_rules(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - client.list_branch_rules(request) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 +def test_merge_pull_request_rest_bad_request( + request_type=secure_source_manager.MergePullRequestRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.merge_pull_request(request) -def test_list_branch_rules_rest_required_fields( - request_type=secure_source_manager.ListBranchRulesRequest, -): - transport_class = transports.SecureSourceManagerRestTransport - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.MergePullRequestRequest, + dict, + ], +) +def test_merge_pull_request_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # verify fields with default values are dropped - - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_branch_rules._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) - # verify required fields with default values are now present + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - jsonified_request["parent"] = "parent_value" + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.merge_pull_request(request) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).list_branch_rules._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "page_size", - "page_token", - ) - ) - jsonified_request.update(unset_fields) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == "parent_value" - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_merge_pull_request_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = secure_source_manager.ListBranchRulesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + client = SecureSourceManagerClient(transport=transport) - response_value = Response() - response_value.status_code = 200 + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_merge_pull_request" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_merge_pull_request_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_merge_pull_request" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.MergePullRequestRequest.pb( + secure_source_manager.MergePullRequestRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Convert return value to protobuf type - return_value = secure_source_manager.ListBranchRulesResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(return_value) + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + request = secure_source_manager.MergePullRequestRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - response = client.list_branch_rules(request) + client.merge_pull_request( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_list_branch_rules_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_open_pull_request_rest_bad_request( + request_type=secure_source_manager.OpenPullRequestRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) - unset_fields = transport.list_branch_rules._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "pageSize", - "pageToken", - ) - ) - & set(("parent",)) - ) + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.open_pull_request(request) -def test_list_branch_rules_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.OpenPullRequestRequest, + dict, + ], +) +def test_open_pull_request_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = secure_source_manager.ListBranchRulesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } - - # get truthy value for each flattened field - mock_args = dict( - parent="parent_value", - ) - mock_args.update(sample_request) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj - response_value = Response() + response_value = mock.Mock() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = secure_source_manager.ListBranchRulesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") + response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.open_pull_request(request) - client.list_branch_rules(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{parent=projects/*/locations/*/repositories/*}/branchRules" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -def test_list_branch_rules_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_open_pull_request_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_branch_rules( - secure_source_manager.ListBranchRulesRequest(), - parent="parent_value", + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_open_pull_request" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_open_pull_request_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_open_pull_request" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.OpenPullRequestRequest.pb( + secure_source_manager.OpenPullRequestRequest() ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value -def test_list_branch_rules_rest_pager(transport: str = "rest"): + request = secure_source_manager.OpenPullRequestRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.open_pull_request( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_close_pull_request_rest_bad_request( + request_type=secure_source_manager.ClosePullRequestRequest, +): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - # with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - ], - next_page_token="abc", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[], - next_page_token="def", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - ], - next_page_token="ghi", - ), - secure_source_manager.ListBranchRulesResponse( - branch_rules=[ - secure_source_manager.BranchRule(), - secure_source_manager.BranchRule(), - ], - ), - ) - # Two responses for two calls - response = response + response + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.close_pull_request(request) - # Wrap the values into proper Response objs - response = tuple( - secure_source_manager.ListBranchRulesResponse.to_json(x) for x in response - ) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode("UTF-8") - return_val.status_code = 200 - req.side_effect = return_values - sample_request = { - "parent": "projects/sample1/locations/sample2/repositories/sample3" - } +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ClosePullRequestRequest, + dict, + ], +) +def test_close_pull_request_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) - pager = client.list_branch_rules(request=sample_request) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.close_pull_request(request) - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, secure_source_manager.BranchRule) for i in results) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) - pages = list(client.list_branch_rules(request=sample_request).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_close_pull_request_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), + ) + client = SecureSourceManagerClient(transport=transport) -def test_get_branch_rule_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_close_pull_request" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_close_pull_request_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_close_pull_request" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.ClosePullRequestRequest.pb( + secure_source_manager.ClosePullRequestRequest() ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - # Ensure method has been cached - assert client._transport.get_branch_rule in client._transport._wrapped_methods + request = secure_source_manager.ClosePullRequestRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + client.close_pull_request( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - client._transport._wrapped_methods[client._transport.get_branch_rule] = mock_rpc - - request = {} - client.get_branch_rule(request) - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - client.get_branch_rule(request) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 +def test_list_pull_request_file_diffs_rest_bad_request( + request_type=secure_source_manager.ListPullRequestFileDiffsRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_pull_request_file_diffs(request) -def test_get_branch_rule_rest_required_fields( - request_type=secure_source_manager.GetBranchRuleRequest, -): - transport_class = transports.SecureSourceManagerRestTransport - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListPullRequestFileDiffsRequest, + dict, + ], +) +def test_list_pull_request_file_diffs_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # verify fields with default values are dropped + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_branch_rule._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListPullRequestFileDiffsResponse( + next_page_token="next_page_token_value", + ) - # verify required fields with default values are now present + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 - jsonified_request["name"] = "name_value" + # Convert return value to protobuf type + return_value = secure_source_manager.ListPullRequestFileDiffsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_pull_request_file_diffs(request) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).get_branch_rule._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPullRequestFileDiffsPager) + assert response.next_page_token == "next_page_token_value" - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_pull_request_file_diffs_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = secure_source_manager.BranchRule() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "get", - "query_params": pb_request, - } - transcode.return_value = transcode_result + client = SecureSourceManagerClient(transport=transport) - response_value = Response() - response_value.status_code = 200 + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_list_pull_request_file_diffs", + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_list_pull_request_file_diffs_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "pre_list_pull_request_file_diffs", + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.ListPullRequestFileDiffsRequest.pb( + secure_source_manager.ListPullRequestFileDiffsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Convert return value to protobuf type - return_value = secure_source_manager.BranchRule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.ListPullRequestFileDiffsResponse.to_json( + secure_source_manager.ListPullRequestFileDiffsResponse() + ) + req.return_value.content = return_value - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + request = secure_source_manager.ListPullRequestFileDiffsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.ListPullRequestFileDiffsResponse() + post_with_metadata.return_value = ( + secure_source_manager.ListPullRequestFileDiffsResponse(), + metadata, + ) - response = client.get_branch_rule(request) + client.list_pull_request_file_diffs( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_get_branch_rule_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_fetch_tree_rest_bad_request( + request_type=secure_source_manager.FetchTreeRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "repository": "projects/sample1/locations/sample2/repositories/sample3" + } + request = request_type(**request_init) - unset_fields = transport.get_branch_rule._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name",))) + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.fetch_tree(request) -def test_get_branch_rule_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.FetchTreeRequest, + dict, + ], +) +def test_fetch_tree_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "repository": "projects/sample1/locations/sample2/repositories/sample3" + } + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = secure_source_manager.BranchRule() - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" - } - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + return_value = secure_source_manager.FetchTreeResponse( + next_page_token="next_page_token_value", ) - mock_args.update(sample_request) # Wrap the value into a proper Response obj - response_value = Response() + response_value = mock.Mock() response_value.status_code = 200 + # Convert return value to protobuf type - return_value = secure_source_manager.BranchRule.pb(return_value) + return_value = secure_source_manager.FetchTreeResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") + response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.fetch_tree(request) - client.get_branch_rule(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/branchRules/*}" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.FetchTreePager) + assert response.next_page_token == "next_page_token_value" -def test_get_branch_rule_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_fetch_tree_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_branch_rule( - secure_source_manager.GetBranchRuleRequest(), - name="name_value", + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_fetch_tree" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_fetch_tree_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_fetch_tree" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.FetchTreeRequest.pb( + secure_source_manager.FetchTreeRequest() ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - -def test_update_branch_rule_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.FetchTreeResponse.to_json( + secure_source_manager.FetchTreeResponse() ) + req.return_value.content = return_value - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._transport.update_branch_rule in client._transport._wrapped_methods + request = secure_source_manager.FetchTreeRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.FetchTreeResponse() + post_with_metadata.return_value = ( + secure_source_manager.FetchTreeResponse(), + metadata, ) - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. + client.fetch_tree( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - client._transport._wrapped_methods[ - client._transport.update_branch_rule - ] = mock_rpc - request = {} - client.update_branch_rule(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - client.update_branch_rule(request) +def test_fetch_blob_rest_bad_request( + request_type=secure_source_manager.FetchBlobRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "repository": "projects/sample1/locations/sample2/repositories/sample3" + } + request = request_type(**request_init) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.fetch_blob(request) -def test_update_branch_rule_rest_required_fields( - request_type=secure_source_manager.UpdateBranchRuleRequest, -): - transport_class = transports.SecureSourceManagerRestTransport +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.FetchBlobRequest, + dict, + ], +) +def test_fetch_blob_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) - request_init = {} + # send a request that will satisfy transcoding + request_init = { + "repository": "projects/sample1/locations/sample2/repositories/sample3" + } request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.FetchBlobResponse( + sha="sha_value", + content="content_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.FetchBlobResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.fetch_blob(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.FetchBlobResponse) + assert response.sha == "sha_value" + assert response.content == "content_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_fetch_blob_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # verify fields with default values are dropped + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_fetch_blob" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_fetch_blob_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_fetch_blob" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.FetchBlobRequest.pb( + secure_source_manager.FetchBlobRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_branch_rule._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.FetchBlobResponse.to_json( + secure_source_manager.FetchBlobResponse() + ) + req.return_value.content = return_value - # verify required fields with default values are now present + request = secure_source_manager.FetchBlobRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.FetchBlobResponse() + post_with_metadata.return_value = ( + secure_source_manager.FetchBlobResponse(), + metadata, + ) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).update_branch_rule._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set( - ( - "update_mask", - "validate_only", + client.fetch_blob( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - ) - jsonified_request.update(unset_fields) - # verify required fields with non-default values are left alone + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + +def test_create_issue_rest_bad_request( + request_type=secure_source_manager.CreateIssueRequest, +): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} request = request_type(**request_init) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "patch", - "query_params": pb_request, - } - transcode_result["body"] = pb_request - transcode.return_value = transcode_result + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_issue(request) - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CreateIssueRequest, + dict, + ], +) +def test_create_issue_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) - response = client.update_branch_rule(request) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init["issue"] = { + "name": "name_value", + "title": "title_value", + "body": "body_value", + "state": 1, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "close_time": {}, + "etag": "etag_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.CreateIssueRequest.meta.fields["issue"] + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] -def test_update_branch_rule_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials - ) + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - unset_fields = transport.update_branch_rule._get_unset_required_fields({}) - assert set(unset_fields) == ( - set( - ( - "updateMask", - "validateOnly", - ) - ) - & set( - ( - "branchRule", - "updateMask", - ) - ) - ) + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] -def test_update_branch_rule_rest_flattened(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["issue"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["issue"][field])): + del request_init["issue"][field][i][subfield] + else: + del request_init["issue"][field][subfield] + request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. return_value = operations_pb2.Operation(name="operations/spam") - # get arguments that satisfy an http rule for this method - sample_request = { - "branch_rule": { - "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" - } - } - - # get truthy value for each flattened field - mock_args = dict( - branch_rule=secure_source_manager.BranchRule(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) - mock_args.update(sample_request) - # Wrap the value into a proper Response obj - response_value = Response() + response_value = mock.Mock() response_value.status_code = 200 json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") + response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_issue(request) - client.update_branch_rule(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{branch_rule.name=projects/*/locations/*/repositories/*/branchRules/*}" - % client.transport._host, - args[1], - ) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -def test_update_branch_rule_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_issue_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_branch_rule( - secure_source_manager.UpdateBranchRuleRequest(), - branch_rule=secure_source_manager.BranchRule(name="name_value"), - update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), - ) - - -def test_delete_branch_rule_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert ( - client._transport.delete_branch_rule in client._transport._wrapped_methods + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_create_issue" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_create_issue_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_create_issue" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.CreateIssueRequest.pb( + secure_source_manager.CreateIssueRequest() ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = ( - "foo" # operation_request.operation in compute client(s) expect a string. - ) - client._transport._wrapped_methods[ - client._transport.delete_branch_rule - ] = mock_rpc + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - request = {} - client.delete_branch_rule(request) + request = secure_source_manager.CreateIssueRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 + client.create_issue( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - client.delete_branch_rule(request) - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 +def test_get_issue_rest_bad_request(request_type=secure_source_manager.GetIssueRequest): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + request = request_type(**request_init) + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_issue(request) -def test_delete_branch_rule_rest_required_fields( - request_type=secure_source_manager.DeleteBranchRuleRequest, -): - transport_class = transports.SecureSourceManagerRestTransport - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads( - json_format.MessageToJson(pb_request, use_integers_for_enums=False) +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetIssueRequest, + dict, + ], +) +def test_get_issue_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # verify fields with default values are dropped + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + request = request_type(**request_init) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_branch_rule._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.Issue( + name="name_value", + title="title_value", + body="body_value", + state=secure_source_manager.Issue.State.OPEN, + etag="etag_value", + ) - # verify required fields with default values are now present + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 - jsonified_request["name"] = "name_value" + # Convert return value to protobuf type + return_value = secure_source_manager.Issue.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_issue(request) - unset_fields = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ).delete_branch_rule._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("allow_missing",)) - jsonified_request.update(unset_fields) + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.Issue) + assert response.name == "name_value" + assert response.title == "title_value" + assert response.body == "body_value" + assert response.state == secure_source_manager.Issue.State.OPEN + assert response.etag == "etag_value" - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == "name_value" - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_issue_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) - request = request_type(**request_init) + client = SecureSourceManagerClient(transport=transport) - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, "transcode") as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - "uri": "v1/sample_method", - "method": "delete", - "query_params": pb_request, - } - transcode.return_value = transcode_result + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_get_issue" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_get_issue_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_get_issue" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.GetIssueRequest.pb( + secure_source_manager.GetIssueRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.Issue.to_json( + secure_source_manager.Issue() + ) + req.return_value.content = return_value - response_value._content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + request = secure_source_manager.GetIssueRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.Issue() + post_with_metadata.return_value = secure_source_manager.Issue(), metadata - response = client.delete_branch_rule(request) + client.get_issue( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) - expected_params = [("$alt", "json;enum-encoding=int")] - actual_params = req.call_args.kwargs["params"] - assert expected_params == actual_params + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_delete_branch_rule_rest_unset_required_fields(): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials +def test_list_issues_rest_bad_request( + request_type=secure_source_manager.ListIssuesRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) - unset_fields = transport.delete_branch_rule._get_unset_required_fields({}) - assert set(unset_fields) == (set(("allowMissing",)) & set(("name",))) + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_issues(request) -def test_delete_branch_rule_rest_flattened(): +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListIssuesRequest, + dict, + ], +) +def test_list_issues_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # get arguments that satisfy an http rule for this method - sample_request = { - "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" - } - - # get truthy value for each flattened field - mock_args = dict( - name="name_value", + return_value = secure_source_manager.ListIssuesResponse( + next_page_token="next_page_token_value", ) - mock_args.update(sample_request) # Wrap the value into a proper Response obj - response_value = Response() + response_value = mock.Mock() response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = secure_source_manager.ListIssuesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode("UTF-8") + response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_issues(request) - client.delete_branch_rule(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate( - "%s/v1/{name=projects/*/locations/*/repositories/*/branchRules/*}" - % client.transport._host, - args[1], - ) - - -def test_delete_branch_rule_rest_flattened_error(transport: str = "rest"): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_branch_rule( - secure_source_manager.DeleteBranchRuleRequest(), - name="name_value", - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.SecureSourceManagerGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListIssuesPager) + assert response.next_page_token == "next_page_token_value" - # It is an error to provide a credentials file and a transport instance. - transport = transports.SecureSourceManagerGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = SecureSourceManagerClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - # It is an error to provide an api_key and a transport instance. - transport = transports.SecureSourceManagerGrpcTransport( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_issues_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = SecureSourceManagerClient( - client_options=options, - transport=transport, + client = SecureSourceManagerClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_list_issues" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_list_issues_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_list_issues" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.ListIssuesRequest.pb( + secure_source_manager.ListIssuesRequest() ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # It is an error to provide an api_key and a credential. - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = SecureSourceManagerClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.ListIssuesResponse.to_json( + secure_source_manager.ListIssuesResponse() ) + req.return_value.content = return_value - # It is an error to provide scopes and a transport instance. - transport = transports.SecureSourceManagerGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = SecureSourceManagerClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, + request = secure_source_manager.ListIssuesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.ListIssuesResponse() + post_with_metadata.return_value = ( + secure_source_manager.ListIssuesResponse(), + metadata, ) + client.list_issues( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.SecureSourceManagerGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = SecureSourceManagerClient(transport=transport) - assert client.transport is transport + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.SecureSourceManagerGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), +def test_update_issue_rest_bad_request( + request_type=secure_source_manager.UpdateIssueRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - channel = transport.grpc_channel - assert channel + # send a request that will satisfy transcoding + request_init = { + "issue": { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + } + request = request_type(**request_init) - transport = transports.SecureSourceManagerGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_issue(request) @pytest.mark.parametrize( - "transport_class", + "request_type", [ - transports.SecureSourceManagerGrpcTransport, - transports.SecureSourceManagerGrpcAsyncIOTransport, - transports.SecureSourceManagerRestTransport, + secure_source_manager.UpdateIssueRequest, + dict, ], ) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - - -def test_transport_kind_grpc(): - transport = SecureSourceManagerClient.get_transport_class("grpc")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "grpc" - - -def test_initialize_client_w_grpc(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc" - ) - assert client is not None - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_instances_empty_call_grpc(): +def test_update_issue_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_instances), "__call__") as call: - call.return_value = secure_source_manager.ListInstancesResponse() - client.list_instances(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.ListInstancesRequest() + # send a request that will satisfy transcoding + request_init = { + "issue": { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + } + request_init["issue"] = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4", + "title": "title_value", + "body": "body_value", + "state": 1, + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "close_time": {}, + "etag": "etag_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 - assert args[0] == request_msg + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.UpdateIssueRequest.meta.fields["issue"] + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_instance_empty_call_grpc(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_instance), "__call__") as call: - call.return_value = secure_source_manager.Instance() - client.get_instance(request=None) + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.GetInstanceRequest() + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] - assert args[0] == request_msg + subfields_not_in_runtime = [] + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["issue"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_instance_empty_call_grpc(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_instance), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_instance(request=None) + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["issue"][field])): + del request_init["issue"][field][i][subfield] + else: + del request_init["issue"][field][subfield] + request = request_type(**request_init) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.CreateInstanceRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - assert args[0] == request_msg + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_issue(request) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_instance_empty_call_grpc(): - client = SecureSourceManagerClient( + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_issue_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_instance), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_instance(request=None) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_update_issue" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_update_issue_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_update_issue" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.UpdateIssueRequest.pb( + secure_source_manager.UpdateIssueRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.DeleteInstanceRequest() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - assert args[0] == request_msg + request = secure_source_manager.UpdateIssueRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_issue( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_repositories_empty_call_grpc(): +def test_delete_issue_rest_bad_request( + request_type=secure_source_manager.DeleteIssueRequest, +): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_repositories), "__call__" - ) as call: - call.return_value = secure_source_manager.ListRepositoriesResponse() - client.list_repositories(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.ListRepositoriesRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_issue(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_repository_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.DeleteIssueRequest, + dict, + ], +) +def test_delete_issue_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_repository), "__call__") as call: - call.return_value = secure_source_manager.Repository() - client.get_repository(request=None) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + request = request_type(**request_init) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.GetRepositoryRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - assert args[0] == request_msg + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_issue(request) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_repository_empty_call_grpc(): - client = SecureSourceManagerClient( + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_issue_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.create_repository), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_repository(request=None) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_delete_issue" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_delete_issue_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_delete_issue" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.DeleteIssueRequest.pb( + secure_source_manager.DeleteIssueRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.CreateRepositoryRequest() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - assert args[0] == request_msg + request = secure_source_manager.DeleteIssueRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + client.delete_issue( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_repository_empty_call_grpc(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_repository), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_repository(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.DeleteRepositoryRequest() +def test_open_issue_rest_bad_request( + request_type=secure_source_manager.OpenIssueRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + request = request_type(**request_init) - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.open_issue(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_iam_policy_repo_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.OpenIssueRequest, + dict, + ], +) +def test_open_issue_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_iam_policy_repo), "__call__" - ) as call: - call.return_value = policy_pb2.Policy() - client.get_iam_policy_repo(request=None) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + request = request_type(**request_init) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.GetIamPolicyRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - assert args[0] == request_msg + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.open_issue(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_set_iam_policy_repo_empty_call_grpc(): - client = SecureSourceManagerClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_open_issue_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.set_iam_policy_repo), "__call__" - ) as call: - call.return_value = policy_pb2.Policy() - client.set_iam_policy_repo(request=None) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_open_issue" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_open_issue_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_open_issue" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.OpenIssueRequest.pb( + secure_source_manager.OpenIssueRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.SetIamPolicyRequest() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - assert args[0] == request_msg + request = secure_source_manager.OpenIssueRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + client.open_issue( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_test_iam_permissions_repo_empty_call_grpc(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions_repo), "__call__" - ) as call: - call.return_value = iam_policy_pb2.TestIamPermissionsResponse() - client.test_iam_permissions_repo(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.TestIamPermissionsRequest() +def test_close_issue_rest_bad_request( + request_type=secure_source_manager.CloseIssueRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + request = request_type(**request_init) - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.close_issue(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_branch_rule_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CloseIssueRequest, + dict, + ], +) +def test_close_issue_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_branch_rule), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_branch_rule(request=None) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + request = request_type(**request_init) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.CreateBranchRuleRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - assert args[0] == request_msg + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.close_issue(request) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_branch_rules_empty_call_grpc(): - client = SecureSourceManagerClient( + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_close_issue_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.list_branch_rules), "__call__" - ) as call: - call.return_value = secure_source_manager.ListBranchRulesResponse() - client.list_branch_rules(request=None) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_close_issue" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_close_issue_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_close_issue" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.CloseIssueRequest.pb( + secure_source_manager.CloseIssueRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.ListBranchRulesRequest() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - assert args[0] == request_msg + request = secure_source_manager.CloseIssueRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + client.close_issue( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_branch_rule_empty_call_grpc(): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: - call.return_value = secure_source_manager.BranchRule() - client.get_branch_rule(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.GetBranchRuleRequest() +def test_get_pull_request_comment_rest_bad_request( + request_type=secure_source_manager.GetPullRequestCommentRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4/pullRequestComments/sample5" + } + request = request_type(**request_init) - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_pull_request_comment(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_branch_rule_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.GetPullRequestCommentRequest, + dict, + ], +) +def test_get_pull_request_comment_rest_call_success(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_branch_rule), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.update_branch_rule(request=None) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4/pullRequestComments/sample5" + } + request = request_type(**request_init) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.UpdateBranchRuleRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.PullRequestComment( + name="name_value", + ) - assert args[0] == request_msg + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = secure_source_manager.PullRequestComment.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_pull_request_comment(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_branch_rule_empty_call_grpc(): - client = SecureSourceManagerClient( + # Establish that the response is the type that we expect. + assert isinstance(response, secure_source_manager.PullRequestComment) + assert response.name == "name_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_pull_request_comment_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.delete_branch_rule), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_branch_rule(request=None) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_get_pull_request_comment" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_get_pull_request_comment_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_get_pull_request_comment" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.GetPullRequestCommentRequest.pb( + secure_source_manager.GetPullRequestCommentRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.DeleteBranchRuleRequest() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.PullRequestComment.to_json( + secure_source_manager.PullRequestComment() + ) + req.return_value.content = return_value - assert args[0] == request_msg + request = secure_source_manager.GetPullRequestCommentRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.PullRequestComment() + post_with_metadata.return_value = ( + secure_source_manager.PullRequestComment(), + metadata, + ) + client.get_pull_request_comment( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -def test_transport_kind_grpc_asyncio(): - transport = SecureSourceManagerAsyncClient.get_transport_class("grpc_asyncio")( - credentials=async_anonymous_credentials() - ) - assert transport.kind == "grpc_asyncio" + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_initialize_client_w_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), transport="grpc_asyncio" +def test_list_pull_request_comments_rest_bad_request( + request_type=secure_source_manager.ListPullRequestCommentsRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - assert client is not None + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_pull_request_comments(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_instances_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.ListPullRequestCommentsRequest, + dict, + ], +) +def test_list_pull_request_comments_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_instances), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - secure_source_manager.ListInstancesResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = secure_source_manager.ListPullRequestCommentsResponse( + next_page_token="next_page_token_value", ) - await client.list_instances(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.ListInstancesRequest() + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 - assert args[0] == request_msg + # Convert return value to protobuf type + return_value = secure_source_manager.ListPullRequestCommentsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_pull_request_comments(request) + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListPullRequestCommentsPager) + assert response.next_page_token == "next_page_token_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_instance_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_pull_request_comments_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_instance), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - secure_source_manager.Instance( - name="name_value", - state=secure_source_manager.Instance.State.CREATING, - state_note=secure_source_manager.Instance.StateNote.PAUSED_CMEK_UNAVAILABLE, - kms_key="kms_key_value", - ) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_list_pull_request_comments" + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_list_pull_request_comments_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_list_pull_request_comments" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.ListPullRequestCommentsRequest.pb( + secure_source_manager.ListPullRequestCommentsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = secure_source_manager.ListPullRequestCommentsResponse.to_json( + secure_source_manager.ListPullRequestCommentsResponse() + ) + req.return_value.content = return_value + + request = secure_source_manager.ListPullRequestCommentsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = secure_source_manager.ListPullRequestCommentsResponse() + post_with_metadata.return_value = ( + secure_source_manager.ListPullRequestCommentsResponse(), + metadata, ) - await client.get_instance(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.GetInstanceRequest() + client.list_pull_request_comments( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) - assert args[0] == request_msg + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_instance_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_create_pull_request_comment_rest_bad_request( + request_type=secure_source_manager.CreatePullRequestCommentRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_instance), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.create_instance(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.CreateInstanceRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_pull_request_comment(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_instance_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.CreatePullRequestCommentRequest, + dict, + ], +) +def test_create_pull_request_comment_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_instance), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.delete_instance(request=None) + # send a request that will satisfy transcoding + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } + request_init["pull_request_comment"] = { + "name": "name_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "review": { + "action_type": 1, + "body": "body_value", + "effective_commit_sha": "effective_commit_sha_value", + }, + "comment": {"body": "body_value"}, + "code": { + "body": "body_value", + "reply": "reply_value", + "position": {"path": "path_value", "line": 424}, + "effective_root_comment": "effective_root_comment_value", + "resolved": True, + "effective_commit_sha": "effective_commit_sha_value", + }, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.DeleteInstanceRequest() + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.CreatePullRequestCommentRequest.meta.fields[ + "pull_request_comment" + ] - assert args[0] == request_msg + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_repositories_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_repositories), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - secure_source_manager.ListRepositoriesResponse( - next_page_token="next_page_token_value", - ) - ) - await client.list_repositories(request=None) + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.ListRepositoriesRequest() + subfields_not_in_runtime = [] - assert args[0] == request_msg + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "pull_request_comment" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_repository_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["pull_request_comment"][field])): + del request_init["pull_request_comment"][field][i][subfield] + else: + del request_init["pull_request_comment"][field][subfield] + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_repository), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - secure_source_manager.Repository( - name="name_value", - description="description_value", - instance="instance_value", - uid="uid_value", - etag="etag_value", - ) - ) - await client.get_repository(request=None) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.GetRepositoryRequest() + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_pull_request_comment(request) - assert args[0] == request_msg + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_repository_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_pull_request_comment_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.create_repository), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_create_pull_request_comment", + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_create_pull_request_comment_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_create_pull_request_comment" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.CreatePullRequestCommentRequest.pb( + secure_source_manager.CreatePullRequestCommentRequest() ) - await client.create_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.CreateRepositoryRequest() - - assert args[0] == request_msg + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_repository_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + request = secure_source_manager.CreatePullRequestCommentRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_repository), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + client.create_pull_request_comment( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) - await client.delete_repository(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.DeleteRepositoryRequest() - assert args[0] == request_msg + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_iam_policy_repo_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_update_pull_request_comment_rest_bad_request( + request_type=secure_source_manager.UpdatePullRequestCommentRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = { + "pull_request_comment": { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4/pullRequestComments/sample5" + } + } + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_iam_policy_repo), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy( - version=774, - etag=b"etag_blob", - ) - ) - await client.get_iam_policy_repo(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.GetIamPolicyRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_pull_request_comment(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_set_iam_policy_repo_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.UpdatePullRequestCommentRequest, + dict, + ], +) +def test_update_pull_request_comment_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.set_iam_policy_repo), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy( - version=774, - etag=b"etag_blob", - ) - ) - await client.set_iam_policy_repo(request=None) + # send a request that will satisfy transcoding + request_init = { + "pull_request_comment": { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4/pullRequestComments/sample5" + } + } + request_init["pull_request_comment"] = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4/pullRequestComments/sample5", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + "review": { + "action_type": 1, + "body": "body_value", + "effective_commit_sha": "effective_commit_sha_value", + }, + "comment": {"body": "body_value"}, + "code": { + "body": "body_value", + "reply": "reply_value", + "position": {"path": "path_value", "line": 424}, + "effective_root_comment": "effective_root_comment_value", + "resolved": True, + "effective_commit_sha": "effective_commit_sha_value", + }, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.SetIamPolicyRequest() + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.UpdatePullRequestCommentRequest.meta.fields[ + "pull_request_comment" + ] - assert args[0] == request_msg + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_test_iam_permissions_repo_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.test_iam_permissions_repo), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - iam_policy_pb2.TestIamPermissionsResponse( - permissions=["permissions_value"], - ) - ) - await client.test_iam_permissions_repo(request=None) + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.TestIamPermissionsRequest() + subfields_not_in_runtime = [] - assert args[0] == request_msg + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "pull_request_comment" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_branch_rule_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["pull_request_comment"][field])): + del request_init["pull_request_comment"][field][i][subfield] + else: + del request_init["pull_request_comment"][field][subfield] + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_branch_rule), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.create_branch_rule(request=None) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.CreateBranchRuleRequest() + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_pull_request_comment(request) - assert args[0] == request_msg + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_branch_rules_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_pull_request_comment_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.list_branch_rules), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - secure_source_manager.ListBranchRulesResponse( - next_page_token="next_page_token_value", - ) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_update_pull_request_comment", + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_update_pull_request_comment_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_update_pull_request_comment" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.UpdatePullRequestCommentRequest.pb( + secure_source_manager.UpdatePullRequestCommentRequest() ) - await client.list_branch_rules(request=None) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.ListBranchRulesRequest() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - assert args[0] == request_msg + request = secure_source_manager.UpdatePullRequestCommentRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + client.update_pull_request_comment( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_branch_rule_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - secure_source_manager.BranchRule( - name="name_value", - uid="uid_value", - etag="etag_value", - include_pattern="include_pattern_value", - disabled=True, - require_pull_request=True, - minimum_reviews_count=2280, - minimum_approvals_count=2491, - require_comments_resolved=True, - allow_stale_reviews=True, - require_linear_history=True, - ) - ) - await client.get_branch_rule(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.GetBranchRuleRequest() +def test_delete_pull_request_comment_rest_bad_request( + request_type=secure_source_manager.DeletePullRequestCommentRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4/pullRequestComments/sample5" + } + request = request_type(**request_init) - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_pull_request_comment(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_branch_rule_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +@pytest.mark.parametrize( + "request_type", + [ + secure_source_manager.DeletePullRequestCommentRequest, + dict, + ], +) +def test_delete_pull_request_comment_rest_call_success(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_branch_rule), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.update_branch_rule(request=None) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4/pullRequestComments/sample5" + } + request = request_type(**request_init) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.UpdateBranchRuleRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - assert args[0] == request_msg + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_pull_request_comment(request) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_branch_rule_empty_call_grpc_asyncio(): - client = SecureSourceManagerAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_pull_request_comment_rest_interceptors(null_interceptor): + transport = transports.SecureSourceManagerRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.SecureSourceManagerRestInterceptor(), ) + client = SecureSourceManagerClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.delete_branch_rule), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_delete_pull_request_comment", + ) as post, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_delete_pull_request_comment_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "pre_delete_pull_request_comment" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = secure_source_manager.DeletePullRequestCommentRequest.pb( + secure_source_manager.DeletePullRequestCommentRequest() ) - await client.delete_branch_rule(request=None) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.DeleteBranchRuleRequest() + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - assert args[0] == request_msg + request = secure_source_manager.DeletePullRequestCommentRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + client.delete_pull_request_comment( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -def test_transport_kind_rest(): - transport = SecureSourceManagerClient.get_transport_class("rest")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "rest" + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -def test_list_instances_rest_bad_request( - request_type=secure_source_manager.ListInstancesRequest, +def test_batch_create_pull_request_comments_rest_bad_request( + request_type=secure_source_manager.BatchCreatePullRequestCommentsRequest, ): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -11635,53 +41102,47 @@ def test_list_instances_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_instances(request) + client.batch_create_pull_request_comments(request) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.ListInstancesRequest, + secure_source_manager.BatchCreatePullRequestCommentsRequest, dict, ], ) -def test_list_instances_rest_call_success(request_type): +def test_batch_create_pull_request_comments_rest_call_success(request_type): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = secure_source_manager.ListInstancesResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = secure_source_manager.ListInstancesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_instances(request) + response = client.batch_create_pull_request_comments(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListInstancesPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_instances_rest_interceptors(null_interceptor): +def test_batch_create_pull_request_comments_rest_interceptors(null_interceptor): transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -11695,18 +41156,22 @@ def test_list_instances_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_list_instances" + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_batch_create_pull_request_comments", ) as post, mock.patch.object( transports.SecureSourceManagerRestInterceptor, - "post_list_instances_with_metadata", + "post_batch_create_pull_request_comments_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_list_instances" + transports.SecureSourceManagerRestInterceptor, + "pre_batch_create_pull_request_comments", ) as pre: pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = secure_source_manager.ListInstancesRequest.pb( - secure_source_manager.ListInstancesRequest() + pb_message = secure_source_manager.BatchCreatePullRequestCommentsRequest.pb( + secure_source_manager.BatchCreatePullRequestCommentsRequest() ) transcode.return_value = { "method": "post", @@ -11718,24 +41183,19 @@ def test_list_instances_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = secure_source_manager.ListInstancesResponse.to_json( - secure_source_manager.ListInstancesResponse() - ) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = secure_source_manager.ListInstancesRequest() + request = secure_source_manager.BatchCreatePullRequestCommentsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = secure_source_manager.ListInstancesResponse() - post_with_metadata.return_value = ( - secure_source_manager.ListInstancesResponse(), - metadata, - ) + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.list_instances( + client.batch_create_pull_request_comments( request, metadata=[ ("key", "val"), @@ -11748,14 +41208,16 @@ def test_list_instances_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_get_instance_rest_bad_request( - request_type=secure_source_manager.GetInstanceRequest, +def test_resolve_pull_request_comments_rest_bad_request( + request_type=secure_source_manager.ResolvePullRequestCommentsRequest, ): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/instances/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -11770,60 +41232,47 @@ def test_get_instance_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_instance(request) + client.resolve_pull_request_comments(request) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.GetInstanceRequest, + secure_source_manager.ResolvePullRequestCommentsRequest, dict, ], ) -def test_get_instance_rest_call_success(request_type): +def test_resolve_pull_request_comments_rest_call_success(request_type): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/instances/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = secure_source_manager.Instance( - name="name_value", - state=secure_source_manager.Instance.State.CREATING, - state_note=secure_source_manager.Instance.StateNote.PAUSED_CMEK_UNAVAILABLE, - kms_key="kms_key_value", - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = secure_source_manager.Instance.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_instance(request) + response = client.resolve_pull_request_comments(request) # Establish that the response is the type that we expect. - assert isinstance(response, secure_source_manager.Instance) - assert response.name == "name_value" - assert response.state == secure_source_manager.Instance.State.CREATING - assert ( - response.state_note - == secure_source_manager.Instance.StateNote.PAUSED_CMEK_UNAVAILABLE - ) - assert response.kms_key == "kms_key_value" + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_instance_rest_interceptors(null_interceptor): +def test_resolve_pull_request_comments_rest_interceptors(null_interceptor): transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -11837,17 +41286,22 @@ def test_get_instance_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_get_instance" + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, + "post_resolve_pull_request_comments", ) as post, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_get_instance_with_metadata" + transports.SecureSourceManagerRestInterceptor, + "post_resolve_pull_request_comments_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_get_instance" + transports.SecureSourceManagerRestInterceptor, + "pre_resolve_pull_request_comments", ) as pre: pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = secure_source_manager.GetInstanceRequest.pb( - secure_source_manager.GetInstanceRequest() + pb_message = secure_source_manager.ResolvePullRequestCommentsRequest.pb( + secure_source_manager.ResolvePullRequestCommentsRequest() ) transcode.return_value = { "method": "post", @@ -11859,21 +41313,19 @@ def test_get_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = secure_source_manager.Instance.to_json( - secure_source_manager.Instance() - ) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = secure_source_manager.GetInstanceRequest() + request = secure_source_manager.ResolvePullRequestCommentsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = secure_source_manager.Instance() - post_with_metadata.return_value = secure_source_manager.Instance(), metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.get_instance( + client.resolve_pull_request_comments( request, metadata=[ ("key", "val"), @@ -11886,14 +41338,16 @@ def test_get_instance_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_create_instance_rest_bad_request( - request_type=secure_source_manager.CreateInstanceRequest, +def test_unresolve_pull_request_comments_rest_bad_request( + request_type=secure_source_manager.UnresolvePullRequestCommentsRequest, ): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -11908,115 +41362,25 @@ def test_create_instance_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_instance(request) + client.unresolve_pull_request_comments(request) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.CreateInstanceRequest, + secure_source_manager.UnresolvePullRequestCommentsRequest, dict, ], ) -def test_create_instance_rest_call_success(request_type): +def test_unresolve_pull_request_comments_rest_call_success(request_type): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["instance"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "labels": {}, - "private_config": { - "is_private": True, - "ca_pool": "ca_pool_value", - "http_service_attachment": "http_service_attachment_value", - "ssh_service_attachment": "ssh_service_attachment_value", - "psc_allowed_projects": [ - "psc_allowed_projects_value1", - "psc_allowed_projects_value2", - ], - }, - "state": 1, - "state_note": 1, - "kms_key": "kms_key_value", - "host_config": { - "html": "html_value", - "api": "api_value", - "git_http": "git_http_value", - "git_ssh": "git_ssh_value", - }, + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/pullRequests/sample4" } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = secure_source_manager.CreateInstanceRequest.meta.fields["instance"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["instance"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["instance"][field])): - del request_init["instance"][field][i][subfield] - else: - del request_init["instance"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -12031,14 +41395,14 @@ def get_message_fields(field): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_instance(request) + response = client.unresolve_pull_request_comments(request) # Establish that the response is the type that we expect. json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_instance_rest_interceptors(null_interceptor): +def test_unresolve_pull_request_comments_rest_interceptors(null_interceptor): transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -12054,18 +41418,20 @@ def test_create_instance_rest_interceptors(null_interceptor): ) as transcode, mock.patch.object( operation.Operation, "_set_result_from_operation" ), mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_create_instance" + transports.SecureSourceManagerRestInterceptor, + "post_unresolve_pull_request_comments", ) as post, mock.patch.object( transports.SecureSourceManagerRestInterceptor, - "post_create_instance_with_metadata", + "post_unresolve_pull_request_comments_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_create_instance" + transports.SecureSourceManagerRestInterceptor, + "pre_unresolve_pull_request_comments", ) as pre: pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = secure_source_manager.CreateInstanceRequest.pb( - secure_source_manager.CreateInstanceRequest() + pb_message = secure_source_manager.UnresolvePullRequestCommentsRequest.pb( + secure_source_manager.UnresolvePullRequestCommentsRequest() ) transcode.return_value = { "method": "post", @@ -12080,7 +41446,7 @@ def test_create_instance_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = secure_source_manager.CreateInstanceRequest() + request = secure_source_manager.UnresolvePullRequestCommentsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -12089,7 +41455,7 @@ def test_create_instance_rest_interceptors(null_interceptor): post.return_value = operations_pb2.Operation() post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.create_instance( + client.unresolve_pull_request_comments( request, metadata=[ ("key", "val"), @@ -12102,14 +41468,16 @@ def test_create_instance_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_delete_instance_rest_bad_request( - request_type=secure_source_manager.DeleteInstanceRequest, +def test_create_issue_comment_rest_bad_request( + request_type=secure_source_manager.CreateIssueCommentRequest, ): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/instances/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -12124,23 +41492,100 @@ def test_delete_instance_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_instance(request) + client.create_issue_comment(request) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.DeleteInstanceRequest, + secure_source_manager.CreateIssueCommentRequest, dict, ], ) -def test_delete_instance_rest_call_success(request_type): +def test_create_issue_comment_rest_call_success(request_type): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/instances/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } + request_init["issue_comment"] = { + "name": "name_value", + "body": "body_value", + "create_time": {"seconds": 751, "nanos": 543}, + "update_time": {}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = secure_source_manager.CreateIssueCommentRequest.meta.fields[ + "issue_comment" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["issue_comment"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["issue_comment"][field])): + del request_init["issue_comment"][field][i][subfield] + else: + del request_init["issue_comment"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -12155,14 +41600,14 @@ def test_delete_instance_rest_call_success(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_instance(request) + response = client.create_issue_comment(request) # Establish that the response is the type that we expect. json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_instance_rest_interceptors(null_interceptor): +def test_create_issue_comment_rest_interceptors(null_interceptor): transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -12178,18 +41623,18 @@ def test_delete_instance_rest_interceptors(null_interceptor): ) as transcode, mock.patch.object( operation.Operation, "_set_result_from_operation" ), mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_delete_instance" + transports.SecureSourceManagerRestInterceptor, "post_create_issue_comment" ) as post, mock.patch.object( transports.SecureSourceManagerRestInterceptor, - "post_delete_instance_with_metadata", + "post_create_issue_comment_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_delete_instance" + transports.SecureSourceManagerRestInterceptor, "pre_create_issue_comment" ) as pre: pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = secure_source_manager.DeleteInstanceRequest.pb( - secure_source_manager.DeleteInstanceRequest() + pb_message = secure_source_manager.CreateIssueCommentRequest.pb( + secure_source_manager.CreateIssueCommentRequest() ) transcode.return_value = { "method": "post", @@ -12204,7 +41649,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = secure_source_manager.DeleteInstanceRequest() + request = secure_source_manager.CreateIssueCommentRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -12213,7 +41658,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): post.return_value = operations_pb2.Operation() post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.delete_instance( + client.create_issue_comment( request, metadata=[ ("key", "val"), @@ -12226,14 +41671,16 @@ def test_delete_instance_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_list_repositories_rest_bad_request( - request_type=secure_source_manager.ListRepositoriesRequest, +def test_get_issue_comment_rest_bad_request( + request_type=secure_source_manager.GetIssueCommentRequest, ): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4/issueComments/sample5" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -12248,30 +41695,33 @@ def test_list_repositories_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_repositories(request) + client.get_issue_comment(request) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.ListRepositoriesRequest, + secure_source_manager.GetIssueCommentRequest, dict, ], ) -def test_list_repositories_rest_call_success(request_type): +def test_get_issue_comment_rest_call_success(request_type): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4/issueComments/sample5" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = secure_source_manager.ListRepositoriesResponse( - next_page_token="next_page_token_value", + return_value = secure_source_manager.IssueComment( + name="name_value", + body="body_value", ) # Wrap the value into a proper Response obj @@ -12279,20 +41729,21 @@ def test_list_repositories_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = secure_source_manager.ListRepositoriesResponse.pb(return_value) + return_value = secure_source_manager.IssueComment.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_repositories(request) + response = client.get_issue_comment(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRepositoriesPager) - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, secure_source_manager.IssueComment) + assert response.name == "name_value" + assert response.body == "body_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_repositories_rest_interceptors(null_interceptor): +def test_get_issue_comment_rest_interceptors(null_interceptor): transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -12306,18 +41757,18 @@ def test_list_repositories_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_list_repositories" + transports.SecureSourceManagerRestInterceptor, "post_get_issue_comment" ) as post, mock.patch.object( transports.SecureSourceManagerRestInterceptor, - "post_list_repositories_with_metadata", + "post_get_issue_comment_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_list_repositories" + transports.SecureSourceManagerRestInterceptor, "pre_get_issue_comment" ) as pre: pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = secure_source_manager.ListRepositoriesRequest.pb( - secure_source_manager.ListRepositoriesRequest() + pb_message = secure_source_manager.GetIssueCommentRequest.pb( + secure_source_manager.GetIssueCommentRequest() ) transcode.return_value = { "method": "post", @@ -12329,24 +41780,21 @@ def test_list_repositories_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = secure_source_manager.ListRepositoriesResponse.to_json( - secure_source_manager.ListRepositoriesResponse() + return_value = secure_source_manager.IssueComment.to_json( + secure_source_manager.IssueComment() ) req.return_value.content = return_value - request = secure_source_manager.ListRepositoriesRequest() + request = secure_source_manager.GetIssueCommentRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = secure_source_manager.ListRepositoriesResponse() - post_with_metadata.return_value = ( - secure_source_manager.ListRepositoriesResponse(), - metadata, - ) + post.return_value = secure_source_manager.IssueComment() + post_with_metadata.return_value = secure_source_manager.IssueComment(), metadata - client.list_repositories( + client.get_issue_comment( request, metadata=[ ("key", "val"), @@ -12359,14 +41807,16 @@ def test_list_repositories_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_get_repository_rest_bad_request( - request_type=secure_source_manager.GetRepositoryRequest, +def test_list_issue_comments_rest_bad_request( + request_type=secure_source_manager.ListIssueCommentsRequest, ): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -12381,34 +41831,32 @@ def test_get_repository_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_repository(request) + client.list_issue_comments(request) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.GetRepositoryRequest, + secure_source_manager.ListIssueCommentsRequest, dict, ], ) -def test_get_repository_rest_call_success(request_type): +def test_list_issue_comments_rest_call_success(request_type): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = { + "parent": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4" + } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = secure_source_manager.Repository( - name="name_value", - description="description_value", - instance="instance_value", - uid="uid_value", - etag="etag_value", + return_value = secure_source_manager.ListIssueCommentsResponse( + next_page_token="next_page_token_value", ) # Wrap the value into a proper Response obj @@ -12416,24 +41864,20 @@ def test_get_repository_rest_call_success(request_type): response_value.status_code = 200 # Convert return value to protobuf type - return_value = secure_source_manager.Repository.pb(return_value) + return_value = secure_source_manager.ListIssueCommentsResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_repository(request) + response = client.list_issue_comments(request) # Establish that the response is the type that we expect. - assert isinstance(response, secure_source_manager.Repository) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.instance == "instance_value" - assert response.uid == "uid_value" - assert response.etag == "etag_value" + assert isinstance(response, pagers.ListIssueCommentsPager) + assert response.next_page_token == "next_page_token_value" @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_repository_rest_interceptors(null_interceptor): +def test_list_issue_comments_rest_interceptors(null_interceptor): transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -12447,18 +41891,18 @@ def test_get_repository_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_get_repository" + transports.SecureSourceManagerRestInterceptor, "post_list_issue_comments" ) as post, mock.patch.object( transports.SecureSourceManagerRestInterceptor, - "post_get_repository_with_metadata", + "post_list_issue_comments_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_get_repository" + transports.SecureSourceManagerRestInterceptor, "pre_list_issue_comments" ) as pre: pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = secure_source_manager.GetRepositoryRequest.pb( - secure_source_manager.GetRepositoryRequest() + pb_message = secure_source_manager.ListIssueCommentsRequest.pb( + secure_source_manager.ListIssueCommentsRequest() ) transcode.return_value = { "method": "post", @@ -12470,21 +41914,24 @@ def test_get_repository_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = secure_source_manager.Repository.to_json( - secure_source_manager.Repository() + return_value = secure_source_manager.ListIssueCommentsResponse.to_json( + secure_source_manager.ListIssueCommentsResponse() ) req.return_value.content = return_value - request = secure_source_manager.GetRepositoryRequest() + request = secure_source_manager.ListIssueCommentsRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = secure_source_manager.Repository() - post_with_metadata.return_value = secure_source_manager.Repository(), metadata + post.return_value = secure_source_manager.ListIssueCommentsResponse() + post_with_metadata.return_value = ( + secure_source_manager.ListIssueCommentsResponse(), + metadata, + ) - client.get_repository( + client.list_issue_comments( request, metadata=[ ("key", "val"), @@ -12497,14 +41944,18 @@ def test_get_repository_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_create_repository_rest_bad_request( - request_type=secure_source_manager.CreateRepositoryRequest, +def test_update_issue_comment_rest_bad_request( + request_type=secure_source_manager.UpdateIssueCommentRequest, ): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} + request_init = { + "issue_comment": { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4/issueComments/sample5" + } + } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -12519,49 +41970,41 @@ def test_create_repository_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_repository(request) + client.update_issue_comment(request) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.CreateRepositoryRequest, + secure_source_manager.UpdateIssueCommentRequest, dict, ], ) -def test_create_repository_rest_call_success(request_type): +def test_update_issue_comment_rest_call_success(request_type): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["repository"] = { - "name": "name_value", - "description": "description_value", - "instance": "instance_value", - "uid": "uid_value", + request_init = { + "issue_comment": { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4/issueComments/sample5" + } + } + request_init["issue_comment"] = { + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4/issueComments/sample5", + "body": "body_value", "create_time": {"seconds": 751, "nanos": 543}, "update_time": {}, - "etag": "etag_value", - "uris": { - "html": "html_value", - "git_https": "git_https_value", - "api": "api_value", - }, - "initial_config": { - "default_branch": "default_branch_value", - "gitignores": ["gitignores_value1", "gitignores_value2"], - "license_": "license__value", - "readme": "readme_value", - }, } # The version of a generated dependency at test runtime may differ from the version used during generation. # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 # Determine if the message type is proto-plus or protobuf - test_field = secure_source_manager.CreateRepositoryRequest.meta.fields["repository"] + test_field = secure_source_manager.UpdateIssueCommentRequest.meta.fields[ + "issue_comment" + ] def get_message_fields(field): # Given a field which is a message (composite type), return a list with @@ -12589,7 +42032,7 @@ def get_message_fields(field): # For each item in the sample request, create a list of sub fields which are not present at runtime # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["repository"].items(): # pragma: NO COVER + for field, value in request_init["issue_comment"].items(): # pragma: NO COVER result = None is_repeated = False # For repeated fields @@ -12611,142 +42054,18 @@ def get_message_fields(field): } ) - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["repository"][field])): - del request_init["repository"][field][i][subfield] - else: - del request_init["repository"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_repository(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_repository_rest_interceptors(null_interceptor): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.SecureSourceManagerRestInterceptor(), - ) - client = SecureSourceManagerClient(transport=transport) - - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_create_repository" - ) as post, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, - "post_create_repository_with_metadata", - ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_create_repository" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = secure_source_manager.CreateRepositoryRequest.pb( - secure_source_manager.CreateRepositoryRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = secure_source_manager.CreateRepositoryRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_repository( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_repository_rest_bad_request( - request_type=secure_source_manager.DeleteRepositoryRequest, -): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_repository(request) - - -@pytest.mark.parametrize( - "request_type", - [ - secure_source_manager.DeleteRepositoryRequest, - dict, - ], -) -def test_delete_repository_rest_call_success(request_type): - client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {"name": "projects/sample1/locations/sample2/repositories/sample3"} + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["issue_comment"][field])): + del request_init["issue_comment"][field][i][subfield] + else: + del request_init["issue_comment"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -12761,14 +42080,14 @@ def test_delete_repository_rest_call_success(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_repository(request) + response = client.update_issue_comment(request) # Establish that the response is the type that we expect. json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_repository_rest_interceptors(null_interceptor): +def test_update_issue_comment_rest_interceptors(null_interceptor): transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -12784,18 +42103,18 @@ def test_delete_repository_rest_interceptors(null_interceptor): ) as transcode, mock.patch.object( operation.Operation, "_set_result_from_operation" ), mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_delete_repository" + transports.SecureSourceManagerRestInterceptor, "post_update_issue_comment" ) as post, mock.patch.object( transports.SecureSourceManagerRestInterceptor, - "post_delete_repository_with_metadata", + "post_update_issue_comment_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_delete_repository" + transports.SecureSourceManagerRestInterceptor, "pre_update_issue_comment" ) as pre: pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = secure_source_manager.DeleteRepositoryRequest.pb( - secure_source_manager.DeleteRepositoryRequest() + pb_message = secure_source_manager.UpdateIssueCommentRequest.pb( + secure_source_manager.UpdateIssueCommentRequest() ) transcode.return_value = { "method": "post", @@ -12810,7 +42129,7 @@ def test_delete_repository_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = secure_source_manager.DeleteRepositoryRequest() + request = secure_source_manager.UpdateIssueCommentRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), @@ -12819,7 +42138,7 @@ def test_delete_repository_rest_interceptors(null_interceptor): post.return_value = operations_pb2.Operation() post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.delete_repository( + client.update_issue_comment( request, metadata=[ ("key", "val"), @@ -12832,15 +42151,15 @@ def test_delete_repository_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_get_iam_policy_repo_rest_bad_request( - request_type=iam_policy_pb2.GetIamPolicyRequest, +def test_delete_issue_comment_rest_bad_request( + request_type=secure_source_manager.DeleteIssueCommentRequest, ): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4/issueComments/sample5" } request = request_type(**request_init) @@ -12856,34 +42175,31 @@ def test_get_iam_policy_repo_rest_bad_request( response_value.request = mock.Mock() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_iam_policy_repo(request) + client.delete_issue_comment(request) @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.GetIamPolicyRequest, + secure_source_manager.DeleteIssueCommentRequest, dict, ], ) -def test_get_iam_policy_repo_rest_call_success(request_type): +def test_delete_issue_comment_rest_call_success(request_type): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) # send a request that will satisfy transcoding request_init = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" + "name": "projects/sample1/locations/sample2/repositories/sample3/issues/sample4/issueComments/sample5" } request = request_type(**request_init) # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), "request") as req: # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy( - version=774, - etag=b"etag_blob", - ) + return_value = operations_pb2.Operation(name="operations/spam") # Wrap the value into a proper Response obj response_value = mock.Mock() @@ -12892,16 +42208,14 @@ def test_get_iam_policy_repo_rest_call_success(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_iam_policy_repo(request) + response = client.delete_issue_comment(request) # Establish that the response is the type that we expect. - assert isinstance(response, policy_pb2.Policy) - assert response.version == 774 - assert response.etag == b"etag_blob" + json_return_value = json_format.MessageToJson(return_value) @pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_iam_policy_repo_rest_interceptors(null_interceptor): +def test_delete_issue_comment_rest_interceptors(null_interceptor): transport = transports.SecureSourceManagerRestTransport( credentials=ga_credentials.AnonymousCredentials(), interceptor=None @@ -12915,17 +42229,21 @@ def test_get_iam_policy_repo_rest_interceptors(null_interceptor): ) as req, mock.patch.object( path_template, "transcode" ) as transcode, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_get_iam_policy_repo" + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.SecureSourceManagerRestInterceptor, "post_delete_issue_comment" ) as post, mock.patch.object( transports.SecureSourceManagerRestInterceptor, - "post_get_iam_policy_repo_with_metadata", + "post_delete_issue_comment_with_metadata", ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_get_iam_policy_repo" + transports.SecureSourceManagerRestInterceptor, "pre_delete_issue_comment" ) as pre: pre.assert_not_called() post.assert_not_called() post_with_metadata.assert_not_called() - pb_message = iam_policy_pb2.GetIamPolicyRequest() + pb_message = secure_source_manager.DeleteIssueCommentRequest.pb( + secure_source_manager.DeleteIssueCommentRequest() + ) transcode.return_value = { "method": "post", "uri": "my_uri", @@ -12936,19 +42254,19 @@ def test_get_iam_policy_repo_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(policy_pb2.Policy()) + return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = iam_policy_pb2.GetIamPolicyRequest() + request = secure_source_manager.DeleteIssueCommentRequest() metadata = [ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = policy_pb2.Policy() - post_with_metadata.return_value = policy_pb2.Policy(), metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - client.get_iam_policy_repo( + client.delete_issue_comment( request, metadata=[ ("key", "val"), @@ -12961,1754 +42279,1408 @@ def test_get_iam_policy_repo_rest_interceptors(null_interceptor): post_with_metadata.assert_called_once() -def test_set_iam_policy_repo_rest_bad_request( - request_type=iam_policy_pb2.SetIamPolicyRequest, -): +def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationRequest): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2"}, request ) - # send a request that will satisfy transcoding - request_init = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" - } - request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. with mock.patch.object(Session, "request") as req, pytest.raises( core_exceptions.BadRequest ): # Wrap the value into a proper Response obj - response_value = mock.Mock() + response_value = Response() json_return_value = "" response_value.json = mock.Mock(return_value={}) response_value.status_code = 400 - response_value.request = mock.Mock() + response_value.request = Request() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.set_iam_policy_repo(request) + client.get_location(request) @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.SetIamPolicyRequest, + locations_pb2.GetLocationRequest, dict, ], ) -def test_set_iam_policy_repo_rest_call_success(request_type): +def test_get_location_rest(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" - } + request_init = {"name": "projects/sample1/locations/sample2"} request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: + with mock.patch.object(Session, "request") as req: # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy( - version=774, - etag=b"etag_blob", - ) + return_value = locations_pb2.Location() # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.set_iam_policy_repo(request) + + response = client.get_location(request) # Establish that the response is the type that we expect. - assert isinstance(response, policy_pb2.Policy) - assert response.version == 774 - assert response.etag == b"etag_blob" + assert isinstance(response, locations_pb2.Location) -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_set_iam_policy_repo_rest_interceptors(null_interceptor): - transport = transports.SecureSourceManagerRestTransport( +def test_list_locations_rest_bad_request( + request_type=locations_pb2.ListLocationsRequest, +): + client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.SecureSourceManagerRestInterceptor(), + transport="rest", ) - client = SecureSourceManagerClient(transport=transport) + request = request_type() + request = json_format.ParseDict({"name": "projects/sample1"}, request) - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_set_iam_policy_repo" - ) as post, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, - "post_set_iam_policy_repo_with_metadata", - ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_set_iam_policy_repo" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = iam_policy_pb2.SetIamPolicyRequest() - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_locations(request) - req.return_value = mock.Mock() - req.return_value.status_code = 200 + +@pytest.mark.parametrize( + "request_type", + [ + locations_pb2.ListLocationsRequest, + dict, + ], +) +def test_list_locations_rest(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + request_init = {"name": "projects/sample1"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # Designate an appropriate value for the returned response. + return_value = locations_pb2.ListLocationsResponse() + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + + req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(policy_pb2.Policy()) - req.return_value.content = return_value - request = iam_policy_pb2.SetIamPolicyRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = policy_pb2.Policy() - post_with_metadata.return_value = policy_pb2.Policy(), metadata + response = client.list_locations(request) - client.set_iam_policy_repo( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) + # Establish that the response is the type that we expect. + assert isinstance(response, locations_pb2.ListLocationsResponse) + + +def test_get_iam_policy_rest_bad_request( + request_type=iam_policy_pb2.GetIamPolicyRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"resource": "projects/sample1/locations/sample2/instances/sample3"}, request + ) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_iam_policy(request) + + +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.GetIamPolicyRequest, + dict, + ], +) +def test_get_iam_policy_rest(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + request_init = {"resource": "projects/sample1/locations/sample2/instances/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # Designate an appropriate value for the returned response. + return_value = policy_pb2.Policy() + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_iam_policy(request) -def test_test_iam_permissions_repo_rest_bad_request( - request_type=iam_policy_pb2.TestIamPermissionsRequest, + # Establish that the response is the type that we expect. + assert isinstance(response, policy_pb2.Policy) + + +def test_set_iam_policy_rest_bad_request( + request_type=iam_policy_pb2.SetIamPolicyRequest, ): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"resource": "projects/sample1/locations/sample2/instances/sample3"}, request ) - # send a request that will satisfy transcoding - request_init = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" - } - request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. with mock.patch.object(Session, "request") as req, pytest.raises( core_exceptions.BadRequest ): # Wrap the value into a proper Response obj - response_value = mock.Mock() + response_value = Response() json_return_value = "" response_value.json = mock.Mock(return_value={}) response_value.status_code = 400 - response_value.request = mock.Mock() + response_value.request = Request() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.test_iam_permissions_repo(request) + client.set_iam_policy(request) @pytest.mark.parametrize( "request_type", [ - iam_policy_pb2.TestIamPermissionsRequest, + iam_policy_pb2.SetIamPolicyRequest, dict, ], ) -def test_test_iam_permissions_repo_rest_call_success(request_type): +def test_set_iam_policy_rest(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = { - "resource": "projects/sample1/locations/sample2/repositories/sample3" - } + request_init = {"resource": "projects/sample1/locations/sample2/instances/sample3"} request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: + with mock.patch.object(Session, "request") as req: # Designate an appropriate value for the returned response. - return_value = iam_policy_pb2.TestIamPermissionsResponse( - permissions=["permissions_value"], - ) + return_value = policy_pb2.Policy() # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.test_iam_permissions_repo(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) - assert response.permissions == ["permissions_value"] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_test_iam_permissions_repo_rest_interceptors(null_interceptor): - transport = transports.SecureSourceManagerRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.SecureSourceManagerRestInterceptor(), - ) - client = SecureSourceManagerClient(transport=transport) - - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_test_iam_permissions_repo" - ) as post, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, - "post_test_iam_permissions_repo_with_metadata", - ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_test_iam_permissions_repo" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = iam_policy_pb2.TestIamPermissionsRequest() - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - req.return_value = mock.Mock() - req.return_value.status_code = 200 + req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson( - iam_policy_pb2.TestIamPermissionsResponse() - ) - req.return_value.content = return_value - - request = iam_policy_pb2.TestIamPermissionsRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = iam_policy_pb2.TestIamPermissionsResponse() - post_with_metadata.return_value = ( - iam_policy_pb2.TestIamPermissionsResponse(), - metadata, - ) - client.test_iam_permissions_repo( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) + response = client.set_iam_policy(request) - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() + # Establish that the response is the type that we expect. + assert isinstance(response, policy_pb2.Policy) -def test_create_branch_rule_rest_bad_request( - request_type=secure_source_manager.CreateBranchRuleRequest, +def test_test_iam_permissions_rest_bad_request( + request_type=iam_policy_pb2.TestIamPermissionsRequest, ): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"resource": "projects/sample1/locations/sample2/instances/sample3"}, request ) - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} - request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. with mock.patch.object(Session, "request") as req, pytest.raises( core_exceptions.BadRequest ): # Wrap the value into a proper Response obj - response_value = mock.Mock() + response_value = Response() json_return_value = "" response_value.json = mock.Mock(return_value={}) response_value.status_code = 400 - response_value.request = mock.Mock() + response_value.request = Request() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_branch_rule(request) + client.test_iam_permissions(request) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.CreateBranchRuleRequest, + iam_policy_pb2.TestIamPermissionsRequest, dict, ], ) -def test_create_branch_rule_rest_call_success(request_type): +def test_test_iam_permissions_rest(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} - request_init["branch_rule"] = { - "name": "name_value", - "uid": "uid_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "annotations": {}, - "etag": "etag_value", - "include_pattern": "include_pattern_value", - "disabled": True, - "require_pull_request": True, - "minimum_reviews_count": 2280, - "minimum_approvals_count": 2491, - "require_comments_resolved": True, - "allow_stale_reviews": True, - "require_linear_history": True, - "required_status_checks": [{"context": "context_value"}], - } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = secure_source_manager.CreateBranchRuleRequest.meta.fields[ - "branch_rule" - ] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] + request_init = {"resource": "projects/sample1/locations/sample2/instances/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # Designate an appropriate value for the returned response. + return_value = iam_policy_pb2.TestIamPermissionsResponse() - subfields_not_in_runtime = [] + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["branch_rule"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) + response = client.test_iam_permissions(request) - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["branch_rule"][field])): - del request_init["branch_rule"][field][i][subfield] - else: - del request_init["branch_rule"][field][subfield] - request = request_type(**request_init) + # Establish that the response is the type that we expect. + assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") +def test_cancel_operation_rest_bad_request( + request_type=operations_pb2.CancelOperationRequest, +): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2/operations/sample3"}, request + ) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") + response_value = Response() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_branch_rule(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + client.cancel_operation(request) -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_branch_rule_rest_interceptors(null_interceptor): - transport = transports.SecureSourceManagerRestTransport( +@pytest.mark.parametrize( + "request_type", + [ + operations_pb2.CancelOperationRequest, + dict, + ], +) +def test_cancel_operation_rest(request_type): + client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.SecureSourceManagerRestInterceptor(), + transport="rest", ) - client = SecureSourceManagerClient(transport=transport) - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_create_branch_rule" - ) as post, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, - "post_create_branch_rule_with_metadata", - ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_create_branch_rule" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = secure_source_manager.CreateBranchRuleRequest.pb( - secure_source_manager.CreateBranchRuleRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } + request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # Designate an appropriate value for the returned response. + return_value = None - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = "{}" + response_value.content = json_return_value.encode("UTF-8") - request = secure_source_manager.CreateBranchRuleRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_branch_rule( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) + response = client.cancel_operation(request) - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() + # Establish that the response is the type that we expect. + assert response is None -def test_list_branch_rules_rest_bad_request( - request_type=secure_source_manager.ListBranchRulesRequest, +def test_delete_operation_rest_bad_request( + request_type=operations_pb2.DeleteOperationRequest, ): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2/operations/sample3"}, request ) - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} - request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. with mock.patch.object(Session, "request") as req, pytest.raises( core_exceptions.BadRequest ): # Wrap the value into a proper Response obj - response_value = mock.Mock() + response_value = Response() json_return_value = "" response_value.json = mock.Mock(return_value={}) response_value.status_code = 400 - response_value.request = mock.Mock() + response_value.request = Request() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_branch_rules(request) + client.delete_operation(request) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.ListBranchRulesRequest, + operations_pb2.DeleteOperationRequest, dict, ], ) -def test_list_branch_rules_rest_call_success(request_type): +def test_delete_operation_rest(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = {"parent": "projects/sample1/locations/sample2/repositories/sample3"} + request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: + with mock.patch.object(Session, "request") as req: # Designate an appropriate value for the returned response. - return_value = secure_source_manager.ListBranchRulesResponse( - next_page_token="next_page_token_value", - ) + return_value = None # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = secure_source_manager.ListBranchRulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) + json_return_value = "{}" response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_branch_rules(request) + + response = client.delete_operation(request) # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBranchRulesPager) - assert response.next_page_token == "next_page_token_value" + assert response is None -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_branch_rules_rest_interceptors(null_interceptor): - transport = transports.SecureSourceManagerRestTransport( +def test_get_operation_rest_bad_request( + request_type=operations_pb2.GetOperationRequest, +): + client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.SecureSourceManagerRestInterceptor(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2/operations/sample3"}, request ) - client = SecureSourceManagerClient(transport=transport) - - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_list_branch_rules" - ) as post, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, - "post_list_branch_rules_with_metadata", - ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_list_branch_rules" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = secure_source_manager.ListBranchRulesRequest.pb( - secure_source_manager.ListBranchRulesRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - req.return_value = mock.Mock() - req.return_value.status_code = 200 + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = secure_source_manager.ListBranchRulesResponse.to_json( - secure_source_manager.ListBranchRulesResponse() - ) - req.return_value.content = return_value + client.get_operation(request) - request = secure_source_manager.ListBranchRulesRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = secure_source_manager.ListBranchRulesResponse() - post_with_metadata.return_value = ( - secure_source_manager.ListBranchRulesResponse(), - metadata, - ) - client.list_branch_rules( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) +@pytest.mark.parametrize( + "request_type", + [ + operations_pb2.GetOperationRequest, + dict, + ], +) +def test_get_operation_rest(request_type): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation() + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() + response = client.get_operation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) -def test_get_branch_rule_rest_bad_request( - request_type=secure_source_manager.GetBranchRuleRequest, +def test_list_operations_rest_bad_request( + request_type=operations_pb2.ListOperationsRequest, ): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2"}, request ) - # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" - } - request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. with mock.patch.object(Session, "request") as req, pytest.raises( core_exceptions.BadRequest ): # Wrap the value into a proper Response obj - response_value = mock.Mock() + response_value = Response() json_return_value = "" response_value.json = mock.Mock(return_value={}) response_value.status_code = 400 - response_value.request = mock.Mock() + response_value.request = Request() req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_branch_rule(request) + client.list_operations(request) @pytest.mark.parametrize( "request_type", [ - secure_source_manager.GetBranchRuleRequest, + operations_pb2.ListOperationsRequest, dict, ], ) -def test_get_branch_rule_rest_call_success(request_type): +def test_list_operations_rest(request_type): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" - } + request_init = {"name": "projects/sample1/locations/sample2"} request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: + with mock.patch.object(Session, "request") as req: # Designate an appropriate value for the returned response. - return_value = secure_source_manager.BranchRule( - name="name_value", - uid="uid_value", - etag="etag_value", - include_pattern="include_pattern_value", - disabled=True, - require_pull_request=True, - minimum_reviews_count=2280, - minimum_approvals_count=2491, - require_comments_resolved=True, - allow_stale_reviews=True, - require_linear_history=True, - ) + return_value = operations_pb2.ListOperationsResponse() # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = secure_source_manager.BranchRule.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_branch_rule(request) + + response = client.list_operations(request) # Establish that the response is the type that we expect. - assert isinstance(response, secure_source_manager.BranchRule) - assert response.name == "name_value" - assert response.uid == "uid_value" - assert response.etag == "etag_value" - assert response.include_pattern == "include_pattern_value" - assert response.disabled is True - assert response.require_pull_request is True - assert response.minimum_reviews_count == 2280 - assert response.minimum_approvals_count == 2491 - assert response.require_comments_resolved is True - assert response.allow_stale_reviews is True - assert response.require_linear_history is True + assert isinstance(response, operations_pb2.ListOperationsResponse) -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_branch_rule_rest_interceptors(null_interceptor): - transport = transports.SecureSourceManagerRestTransport( +def test_initialize_client_w_rest(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_instances_empty_call_rest(): + client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.SecureSourceManagerRestInterceptor(), + transport="rest", ) - client = SecureSourceManagerClient(transport=transport) + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_instances), "__call__") as call: + client.list_instances(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListInstancesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_instance_empty_call_rest(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_instance), "__call__") as call: + client.get_instance(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetInstanceRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_instance_empty_call_rest(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_instance), "__call__") as call: + client.create_instance(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateInstanceRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_instance_empty_call_rest(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_instance), "__call__") as call: + client.delete_instance(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteInstanceRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_repositories_empty_call_rest(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_get_branch_rule" - ) as post, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, - "post_get_branch_rule_with_metadata", - ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_get_branch_rule" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = secure_source_manager.GetBranchRuleRequest.pb( - secure_source_manager.GetBranchRuleRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } + type(client.transport.list_repositories), "__call__" + ) as call: + client.list_repositories(request=None) - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = secure_source_manager.BranchRule.to_json( - secure_source_manager.BranchRule() - ) - req.return_value.content = return_value + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListRepositoriesRequest() - request = secure_source_manager.GetBranchRuleRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = secure_source_manager.BranchRule() - post_with_metadata.return_value = secure_source_manager.BranchRule(), metadata + assert args[0] == request_msg - client.get_branch_rule( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_repository_empty_call_rest(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_repository), "__call__") as call: + client.get_repository(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetRepositoryRequest() + + assert args[0] == request_msg -def test_update_branch_rule_rest_bad_request( - request_type=secure_source_manager.UpdateBranchRuleRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_repository_empty_call_rest(): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = { - "branch_rule": { - "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" - } - } - request = request_type(**request_init) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_branch_rule(request) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_repository), "__call__" + ) as call: + client.create_repository(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateRepositoryRequest() -@pytest.mark.parametrize( - "request_type", - [ - secure_source_manager.UpdateBranchRuleRequest, - dict, - ], -) -def test_update_branch_rule_rest_call_success(request_type): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_repository_empty_call_rest(): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = { - "branch_rule": { - "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" - } - } - request_init["branch_rule"] = { - "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4", - "uid": "uid_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "annotations": {}, - "etag": "etag_value", - "include_pattern": "include_pattern_value", - "disabled": True, - "require_pull_request": True, - "minimum_reviews_count": 2280, - "minimum_approvals_count": 2491, - "require_comments_resolved": True, - "allow_stale_reviews": True, - "require_linear_history": True, - "required_status_checks": [{"context": "context_value"}], - } - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_repository), "__call__" + ) as call: + client.update_repository(request=None) - # Determine if the message type is proto-plus or protobuf - test_field = secure_source_manager.UpdateBranchRuleRequest.meta.fields[ - "branch_rule" - ] + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateRepositoryRequest() - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] + assert args[0] == request_msg - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_repository_empty_call_rest(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_repository), "__call__" + ) as call: + client.delete_repository(request=None) - subfields_not_in_runtime = [] + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteRepositoryRequest() - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["branch_rule"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value + assert args[0] == request_msg - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - { - "field": field, - "subfield": subfield, - "is_repeated": is_repeated, - } - ) - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["branch_rule"][field])): - del request_init["branch_rule"][field][i][subfield] - else: - del request_init["branch_rule"][field][subfield] - request = request_type(**request_init) +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_hooks_empty_call_rest(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_hooks), "__call__") as call: + client.list_hooks(request=None) - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_branch_rule(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListHooksRequest() - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) + assert args[0] == request_msg -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_branch_rule_rest_interceptors(null_interceptor): - transport = transports.SecureSourceManagerRestTransport( +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_hook_empty_call_rest(): + client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.SecureSourceManagerRestInterceptor(), + transport="rest", ) - client = SecureSourceManagerClient(transport=transport) - - with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_update_branch_rule" - ) as post, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, - "post_update_branch_rule_with_metadata", - ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_update_branch_rule" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = secure_source_manager.UpdateBranchRuleRequest.pb( - secure_source_manager.UpdateBranchRuleRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - request = secure_source_manager.UpdateBranchRuleRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_hook), "__call__") as call: + client.get_hook(request=None) - client.update_branch_rule( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetHookRequest() - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() + assert args[0] == request_msg -def test_delete_branch_rule_rest_bad_request( - request_type=secure_source_manager.DeleteBranchRuleRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_hook_empty_call_rest(): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" - } - request = request_type(**request_init) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_branch_rule(request) + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_hook), "__call__") as call: + client.create_hook(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateHookRequest() + assert args[0] == request_msg -@pytest.mark.parametrize( - "request_type", - [ - secure_source_manager.DeleteBranchRuleRequest, - dict, - ], -) -def test_delete_branch_rule_rest_call_success(request_type): + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_hook_empty_call_rest(): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - # send a request that will satisfy transcoding - request_init = { - "name": "projects/sample1/locations/sample2/repositories/sample3/branchRules/sample4" - } - request = request_type(**request_init) + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_hook), "__call__") as call: + client.update_hook(request=None) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name="operations/spam") + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateHookRequest() - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_branch_rule(request) + assert args[0] == request_msg - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_hook_empty_call_rest(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_hook), "__call__") as call: + client.delete_hook(request=None) -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_branch_rule_rest_interceptors(null_interceptor): - transport = transports.SecureSourceManagerRestTransport( + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteHookRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_iam_policy_repo_empty_call_rest(): + client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), - interceptor=None - if null_interceptor - else transports.SecureSourceManagerRestInterceptor(), + transport="rest", ) - client = SecureSourceManagerClient(transport=transport) + # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport._session), "request" - ) as req, mock.patch.object( - path_template, "transcode" - ) as transcode, mock.patch.object( - operation.Operation, "_set_result_from_operation" - ), mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "post_delete_branch_rule" - ) as post, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, - "post_delete_branch_rule_with_metadata", - ) as post_with_metadata, mock.patch.object( - transports.SecureSourceManagerRestInterceptor, "pre_delete_branch_rule" - ) as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = secure_source_manager.DeleteBranchRuleRequest.pb( - secure_source_manager.DeleteBranchRuleRequest() - ) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } + type(client.transport.get_iam_policy_repo), "__call__" + ) as call: + client.get_iam_policy_repo(request=None) - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.GetIamPolicyRequest() - request = secure_source_manager.DeleteBranchRuleRequest() - metadata = [ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata + assert args[0] == request_msg - client.delete_branch_rule( - request, - metadata=[ - ("key", "val"), - ("cephalopod", "squid"), - ], - ) - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_set_iam_policy_repo_empty_call_rest(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.set_iam_policy_repo), "__call__" + ) as call: + client.set_iam_policy_repo(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.SetIamPolicyRequest() -def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationRequest): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_test_iam_permissions_repo_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request = request_type() - request = json_format.ParseDict( - {"name": "projects/sample1/locations/sample2"}, request - ) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_location(request) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.test_iam_permissions_repo), "__call__" + ) as call: + client.test_iam_permissions_repo(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = iam_policy_pb2.TestIamPermissionsRequest() + assert args[0] == request_msg -@pytest.mark.parametrize( - "request_type", - [ - locations_pb2.GetLocationRequest, - dict, - ], -) -def test_get_location_rest(request_type): + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_branch_rule_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request_init = {"name": "projects/sample1/locations/sample2"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # Designate an appropriate value for the returned response. - return_value = locations_pb2.Location() + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_branch_rule), "__call__" + ) as call: + client.create_branch_rule(request=None) - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateBranchRuleRequest() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_branch_rules_empty_call_rest(): + client = SecureSourceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_branch_rules), "__call__" + ) as call: + client.list_branch_rules(request=None) - response = client.get_location(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListBranchRulesRequest() - # Establish that the response is the type that we expect. - assert isinstance(response, locations_pb2.Location) + assert args[0] == request_msg -def test_list_locations_rest_bad_request( - request_type=locations_pb2.ListLocationsRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_branch_rule_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request = request_type() - request = json_format.ParseDict({"name": "projects/sample1"}, request) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_locations(request) + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: + client.get_branch_rule(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetBranchRuleRequest() -@pytest.mark.parametrize( - "request_type", - [ - locations_pb2.ListLocationsRequest, - dict, - ], -) -def test_list_locations_rest(request_type): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_branch_rule_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request_init = {"name": "projects/sample1"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # Designate an appropriate value for the returned response. - return_value = locations_pb2.ListLocationsResponse() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_branch_rule), "__call__" + ) as call: + client.update_branch_rule(request=None) - response = client.list_locations(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateBranchRuleRequest() - # Establish that the response is the type that we expect. - assert isinstance(response, locations_pb2.ListLocationsResponse) + assert args[0] == request_msg -def test_get_iam_policy_rest_bad_request( - request_type=iam_policy_pb2.GetIamPolicyRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_branch_rule_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request = request_type() - request = json_format.ParseDict( - {"resource": "projects/sample1/locations/sample2/instances/sample3"}, request - ) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_iam_policy(request) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_branch_rule), "__call__" + ) as call: + client.delete_branch_rule(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.DeleteBranchRuleRequest() + assert args[0] == request_msg -@pytest.mark.parametrize( - "request_type", - [ - iam_policy_pb2.GetIamPolicyRequest, - dict, - ], -) -def test_get_iam_policy_rest(request_type): + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_pull_request_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request_init = {"resource": "projects/sample1/locations/sample2/instances/sample3"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_pull_request), "__call__" + ) as call: + client.create_pull_request(request=None) - response = client.get_iam_policy(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreatePullRequestRequest() - # Establish that the response is the type that we expect. - assert isinstance(response, policy_pb2.Policy) + assert args[0] == request_msg -def test_set_iam_policy_rest_bad_request( - request_type=iam_policy_pb2.SetIamPolicyRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_pull_request_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request = request_type() - request = json_format.ParseDict( - {"resource": "projects/sample1/locations/sample2/instances/sample3"}, request - ) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.set_iam_policy(request) + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_pull_request), "__call__") as call: + client.get_pull_request(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetPullRequestRequest() + assert args[0] == request_msg -@pytest.mark.parametrize( - "request_type", - [ - iam_policy_pb2.SetIamPolicyRequest, - dict, - ], -) -def test_set_iam_policy_rest(request_type): + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_pull_requests_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request_init = {"resource": "projects/sample1/locations/sample2/instances/sample3"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # Designate an appropriate value for the returned response. - return_value = policy_pb2.Policy() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_requests), "__call__" + ) as call: + client.list_pull_requests(request=None) - response = client.set_iam_policy(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListPullRequestsRequest() - # Establish that the response is the type that we expect. - assert isinstance(response, policy_pb2.Policy) + assert args[0] == request_msg -def test_test_iam_permissions_rest_bad_request( - request_type=iam_policy_pb2.TestIamPermissionsRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_pull_request_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request = request_type() - request = json_format.ParseDict( - {"resource": "projects/sample1/locations/sample2/instances/sample3"}, request - ) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.test_iam_permissions(request) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_pull_request), "__call__" + ) as call: + client.update_pull_request(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdatePullRequestRequest() -@pytest.mark.parametrize( - "request_type", - [ - iam_policy_pb2.TestIamPermissionsRequest, - dict, - ], -) -def test_test_iam_permissions_rest(request_type): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_merge_pull_request_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request_init = {"resource": "projects/sample1/locations/sample2/instances/sample3"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # Designate an appropriate value for the returned response. - return_value = iam_policy_pb2.TestIamPermissionsResponse() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.merge_pull_request), "__call__" + ) as call: + client.merge_pull_request(request=None) - response = client.test_iam_permissions(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.MergePullRequestRequest() - # Establish that the response is the type that we expect. - assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse) + assert args[0] == request_msg -def test_cancel_operation_rest_bad_request( - request_type=operations_pb2.CancelOperationRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_open_pull_request_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request = request_type() - request = json_format.ParseDict( - {"name": "projects/sample1/locations/sample2/operations/sample3"}, request - ) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.cancel_operation(request) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.open_pull_request), "__call__" + ) as call: + client.open_pull_request(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.OpenPullRequestRequest() -@pytest.mark.parametrize( - "request_type", - [ - operations_pb2.CancelOperationRequest, - dict, - ], -) -def test_cancel_operation_rest(request_type): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_close_pull_request_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = "{}" - response_value.content = json_return_value.encode("UTF-8") - - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.close_pull_request), "__call__" + ) as call: + client.close_pull_request(request=None) - response = client.cancel_operation(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ClosePullRequestRequest() - # Establish that the response is the type that we expect. - assert response is None + assert args[0] == request_msg -def test_delete_operation_rest_bad_request( - request_type=operations_pb2.DeleteOperationRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_pull_request_file_diffs_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request = request_type() - request = json_format.ParseDict( - {"name": "projects/sample1/locations/sample2/operations/sample3"}, request - ) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_operation(request) + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_pull_request_file_diffs), "__call__" + ) as call: + client.list_pull_request_file_diffs(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListPullRequestFileDiffsRequest() -@pytest.mark.parametrize( - "request_type", - [ - operations_pb2.DeleteOperationRequest, - dict, - ], -) -def test_delete_operation_rest(request_type): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_fetch_tree_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = "{}" - response_value.content = json_return_value.encode("UTF-8") - - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.fetch_tree), "__call__") as call: + client.fetch_tree(request=None) - response = client.delete_operation(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.FetchTreeRequest() - # Establish that the response is the type that we expect. - assert response is None + assert args[0] == request_msg -def test_get_operation_rest_bad_request( - request_type=operations_pb2.GetOperationRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_fetch_blob_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request = request_type() - request = json_format.ParseDict( - {"name": "projects/sample1/locations/sample2/operations/sample3"}, request - ) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_operation(request) + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.fetch_blob), "__call__") as call: + client.fetch_blob(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.FetchBlobRequest() -@pytest.mark.parametrize( - "request_type", - [ - operations_pb2.GetOperationRequest, - dict, - ], -) -def test_get_operation_rest(request_type): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_issue_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_issue), "__call__") as call: + client.create_issue(request=None) - response = client.get_operation(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.CreateIssueRequest() - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) + assert args[0] == request_msg -def test_list_operations_rest_bad_request( - request_type=operations_pb2.ListOperationsRequest, -): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_issue_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request = request_type() - request = json_format.ParseDict( - {"name": "projects/sample1/locations/sample2"}, request - ) - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, "request") as req, pytest.raises( - core_exceptions.BadRequest - ): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = "" - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_operations(request) + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_issue), "__call__") as call: + client.get_issue(request=None) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.GetIssueRequest() -@pytest.mark.parametrize( - "request_type", - [ - operations_pb2.ListOperationsRequest, - dict, - ], -) -def test_list_operations_rest(request_type): + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_issues_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) - request_init = {"name": "projects/sample1/locations/sample2"} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, "request") as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.ListOperationsResponse() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode("UTF-8") - - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_issues), "__call__") as call: + client.list_issues(request=None) - response = client.list_operations(request) + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.ListIssuesRequest() - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.ListOperationsResponse) + assert args[0] == request_msg -def test_initialize_client_w_rest(): +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_issue_empty_call_rest(): client = SecureSourceManagerClient( - credentials=ga_credentials.AnonymousCredentials(), transport="rest" + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - assert client is not None + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + client.update_issue(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = secure_source_manager.UpdateIssueRequest() + + assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_instances_empty_call_rest(): +def test_delete_issue_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_instances), "__call__") as call: - client.list_instances(request=None) + with mock.patch.object(type(client.transport.delete_issue), "__call__") as call: + client.delete_issue(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.ListInstancesRequest() + request_msg = secure_source_manager.DeleteIssueRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_instance_empty_call_rest(): +def test_open_issue_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_instance), "__call__") as call: - client.get_instance(request=None) + with mock.patch.object(type(client.transport.open_issue), "__call__") as call: + client.open_issue(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.GetInstanceRequest() + request_msg = secure_source_manager.OpenIssueRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_create_instance_empty_call_rest(): +def test_close_issue_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_instance), "__call__") as call: - client.create_instance(request=None) + with mock.patch.object(type(client.transport.close_issue), "__call__") as call: + client.close_issue(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.CreateInstanceRequest() + request_msg = secure_source_manager.CloseIssueRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_delete_instance_empty_call_rest(): +def test_get_pull_request_comment_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_instance), "__call__") as call: - client.delete_instance(request=None) + with mock.patch.object( + type(client.transport.get_pull_request_comment), "__call__" + ) as call: + client.get_pull_request_comment(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.DeleteInstanceRequest() + request_msg = secure_source_manager.GetPullRequestCommentRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_repositories_empty_call_rest(): +def test_list_pull_request_comments_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -14716,41 +43688,43 @@ def test_list_repositories_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.list_repositories), "__call__" + type(client.transport.list_pull_request_comments), "__call__" ) as call: - client.list_repositories(request=None) + client.list_pull_request_comments(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.ListRepositoriesRequest() + request_msg = secure_source_manager.ListPullRequestCommentsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_repository_empty_call_rest(): +def test_create_pull_request_comment_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_repository), "__call__") as call: - client.get_repository(request=None) + with mock.patch.object( + type(client.transport.create_pull_request_comment), "__call__" + ) as call: + client.create_pull_request_comment(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.GetRepositoryRequest() + request_msg = secure_source_manager.CreatePullRequestCommentRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_create_repository_empty_call_rest(): +def test_update_pull_request_comment_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -14758,21 +43732,21 @@ def test_create_repository_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.create_repository), "__call__" + type(client.transport.update_pull_request_comment), "__call__" ) as call: - client.create_repository(request=None) + client.update_pull_request_comment(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.CreateRepositoryRequest() + request_msg = secure_source_manager.UpdatePullRequestCommentRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_delete_repository_empty_call_rest(): +def test_delete_pull_request_comment_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -14780,21 +43754,21 @@ def test_delete_repository_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.delete_repository), "__call__" + type(client.transport.delete_pull_request_comment), "__call__" ) as call: - client.delete_repository(request=None) + client.delete_pull_request_comment(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.DeleteRepositoryRequest() + request_msg = secure_source_manager.DeletePullRequestCommentRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_iam_policy_repo_empty_call_rest(): +def test_batch_create_pull_request_comments_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -14802,21 +43776,21 @@ def test_get_iam_policy_repo_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.get_iam_policy_repo), "__call__" + type(client.transport.batch_create_pull_request_comments), "__call__" ) as call: - client.get_iam_policy_repo(request=None) + client.batch_create_pull_request_comments(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.GetIamPolicyRequest() + request_msg = secure_source_manager.BatchCreatePullRequestCommentsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_set_iam_policy_repo_empty_call_rest(): +def test_resolve_pull_request_comments_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -14824,21 +43798,21 @@ def test_set_iam_policy_repo_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.set_iam_policy_repo), "__call__" + type(client.transport.resolve_pull_request_comments), "__call__" ) as call: - client.set_iam_policy_repo(request=None) + client.resolve_pull_request_comments(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.SetIamPolicyRequest() + request_msg = secure_source_manager.ResolvePullRequestCommentsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_test_iam_permissions_repo_empty_call_rest(): +def test_unresolve_pull_request_comments_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -14846,21 +43820,21 @@ def test_test_iam_permissions_repo_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.test_iam_permissions_repo), "__call__" + type(client.transport.unresolve_pull_request_comments), "__call__" ) as call: - client.test_iam_permissions_repo(request=None) + client.unresolve_pull_request_comments(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = iam_policy_pb2.TestIamPermissionsRequest() + request_msg = secure_source_manager.UnresolvePullRequestCommentsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_create_branch_rule_empty_call_rest(): +def test_create_issue_comment_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -14868,21 +43842,21 @@ def test_create_branch_rule_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.create_branch_rule), "__call__" + type(client.transport.create_issue_comment), "__call__" ) as call: - client.create_branch_rule(request=None) + client.create_issue_comment(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.CreateBranchRuleRequest() + request_msg = secure_source_manager.CreateIssueCommentRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_list_branch_rules_empty_call_rest(): +def test_get_issue_comment_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -14890,41 +43864,43 @@ def test_list_branch_rules_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.list_branch_rules), "__call__" + type(client.transport.get_issue_comment), "__call__" ) as call: - client.list_branch_rules(request=None) + client.get_issue_comment(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.ListBranchRulesRequest() + request_msg = secure_source_manager.GetIssueCommentRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_get_branch_rule_empty_call_rest(): +def test_list_issue_comments_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", ) # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_branch_rule), "__call__") as call: - client.get_branch_rule(request=None) + with mock.patch.object( + type(client.transport.list_issue_comments), "__call__" + ) as call: + client.list_issue_comments(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.GetBranchRuleRequest() + request_msg = secure_source_manager.ListIssueCommentsRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_update_branch_rule_empty_call_rest(): +def test_update_issue_comment_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -14932,21 +43908,21 @@ def test_update_branch_rule_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.update_branch_rule), "__call__" + type(client.transport.update_issue_comment), "__call__" ) as call: - client.update_branch_rule(request=None) + client.update_issue_comment(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.UpdateBranchRuleRequest() + request_msg = secure_source_manager.UpdateIssueCommentRequest() assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_delete_branch_rule_empty_call_rest(): +def test_delete_issue_comment_empty_call_rest(): client = SecureSourceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest", @@ -14954,14 +43930,14 @@ def test_delete_branch_rule_empty_call_rest(): # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.delete_branch_rule), "__call__" + type(client.transport.delete_issue_comment), "__call__" ) as call: - client.delete_branch_rule(request=None) + client.delete_issue_comment(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = secure_source_manager.DeleteBranchRuleRequest() + request_msg = secure_source_manager.DeleteIssueCommentRequest() assert args[0] == request_msg @@ -15023,7 +43999,13 @@ def test_secure_source_manager_base_transport(): "list_repositories", "get_repository", "create_repository", + "update_repository", "delete_repository", + "list_hooks", + "get_hook", + "create_hook", + "update_hook", + "delete_hook", "get_iam_policy_repo", "set_iam_policy_repo", "test_iam_permissions_repo", @@ -15032,6 +44014,36 @@ def test_secure_source_manager_base_transport(): "get_branch_rule", "update_branch_rule", "delete_branch_rule", + "create_pull_request", + "get_pull_request", + "list_pull_requests", + "update_pull_request", + "merge_pull_request", + "open_pull_request", + "close_pull_request", + "list_pull_request_file_diffs", + "fetch_tree", + "fetch_blob", + "create_issue", + "get_issue", + "list_issues", + "update_issue", + "delete_issue", + "open_issue", + "close_issue", + "get_pull_request_comment", + "list_pull_request_comments", + "create_pull_request_comment", + "update_pull_request_comment", + "delete_pull_request_comment", + "batch_create_pull_request_comments", + "resolve_pull_request_comments", + "unresolve_pull_request_comments", + "create_issue_comment", + "get_issue_comment", + "list_issue_comments", + "update_issue_comment", + "delete_issue_comment", "set_iam_policy", "get_iam_policy", "test_iam_permissions", @@ -15327,9 +44339,27 @@ def test_secure_source_manager_client_transport_session_collision(transport_name session1 = client1.transport.create_repository._session session2 = client2.transport.create_repository._session assert session1 != session2 + session1 = client1.transport.update_repository._session + session2 = client2.transport.update_repository._session + assert session1 != session2 session1 = client1.transport.delete_repository._session session2 = client2.transport.delete_repository._session assert session1 != session2 + session1 = client1.transport.list_hooks._session + session2 = client2.transport.list_hooks._session + assert session1 != session2 + session1 = client1.transport.get_hook._session + session2 = client2.transport.get_hook._session + assert session1 != session2 + session1 = client1.transport.create_hook._session + session2 = client2.transport.create_hook._session + assert session1 != session2 + session1 = client1.transport.update_hook._session + session2 = client2.transport.update_hook._session + assert session1 != session2 + session1 = client1.transport.delete_hook._session + session2 = client2.transport.delete_hook._session + assert session1 != session2 session1 = client1.transport.get_iam_policy_repo._session session2 = client2.transport.get_iam_policy_repo._session assert session1 != session2 @@ -15354,6 +44384,96 @@ def test_secure_source_manager_client_transport_session_collision(transport_name session1 = client1.transport.delete_branch_rule._session session2 = client2.transport.delete_branch_rule._session assert session1 != session2 + session1 = client1.transport.create_pull_request._session + session2 = client2.transport.create_pull_request._session + assert session1 != session2 + session1 = client1.transport.get_pull_request._session + session2 = client2.transport.get_pull_request._session + assert session1 != session2 + session1 = client1.transport.list_pull_requests._session + session2 = client2.transport.list_pull_requests._session + assert session1 != session2 + session1 = client1.transport.update_pull_request._session + session2 = client2.transport.update_pull_request._session + assert session1 != session2 + session1 = client1.transport.merge_pull_request._session + session2 = client2.transport.merge_pull_request._session + assert session1 != session2 + session1 = client1.transport.open_pull_request._session + session2 = client2.transport.open_pull_request._session + assert session1 != session2 + session1 = client1.transport.close_pull_request._session + session2 = client2.transport.close_pull_request._session + assert session1 != session2 + session1 = client1.transport.list_pull_request_file_diffs._session + session2 = client2.transport.list_pull_request_file_diffs._session + assert session1 != session2 + session1 = client1.transport.fetch_tree._session + session2 = client2.transport.fetch_tree._session + assert session1 != session2 + session1 = client1.transport.fetch_blob._session + session2 = client2.transport.fetch_blob._session + assert session1 != session2 + session1 = client1.transport.create_issue._session + session2 = client2.transport.create_issue._session + assert session1 != session2 + session1 = client1.transport.get_issue._session + session2 = client2.transport.get_issue._session + assert session1 != session2 + session1 = client1.transport.list_issues._session + session2 = client2.transport.list_issues._session + assert session1 != session2 + session1 = client1.transport.update_issue._session + session2 = client2.transport.update_issue._session + assert session1 != session2 + session1 = client1.transport.delete_issue._session + session2 = client2.transport.delete_issue._session + assert session1 != session2 + session1 = client1.transport.open_issue._session + session2 = client2.transport.open_issue._session + assert session1 != session2 + session1 = client1.transport.close_issue._session + session2 = client2.transport.close_issue._session + assert session1 != session2 + session1 = client1.transport.get_pull_request_comment._session + session2 = client2.transport.get_pull_request_comment._session + assert session1 != session2 + session1 = client1.transport.list_pull_request_comments._session + session2 = client2.transport.list_pull_request_comments._session + assert session1 != session2 + session1 = client1.transport.create_pull_request_comment._session + session2 = client2.transport.create_pull_request_comment._session + assert session1 != session2 + session1 = client1.transport.update_pull_request_comment._session + session2 = client2.transport.update_pull_request_comment._session + assert session1 != session2 + session1 = client1.transport.delete_pull_request_comment._session + session2 = client2.transport.delete_pull_request_comment._session + assert session1 != session2 + session1 = client1.transport.batch_create_pull_request_comments._session + session2 = client2.transport.batch_create_pull_request_comments._session + assert session1 != session2 + session1 = client1.transport.resolve_pull_request_comments._session + session2 = client2.transport.resolve_pull_request_comments._session + assert session1 != session2 + session1 = client1.transport.unresolve_pull_request_comments._session + session2 = client2.transport.unresolve_pull_request_comments._session + assert session1 != session2 + session1 = client1.transport.create_issue_comment._session + session2 = client2.transport.create_issue_comment._session + assert session1 != session2 + session1 = client1.transport.get_issue_comment._session + session2 = client2.transport.get_issue_comment._session + assert session1 != session2 + session1 = client1.transport.list_issue_comments._session + session2 = client2.transport.list_issue_comments._session + assert session1 != session2 + session1 = client1.transport.update_issue_comment._session + session2 = client2.transport.update_issue_comment._session + assert session1 != session2 + session1 = client1.transport.delete_issue_comment._session + session2 = client2.transport.delete_issue_comment._session + assert session1 != session2 def test_secure_source_manager_grpc_transport_channel(): @@ -15604,10 +44724,39 @@ def test_parse_crypto_key_path(): assert expected == actual -def test_instance_path(): +def test_hook_path(): project = "scallop" location = "abalone" - instance = "squid" + repository = "squid" + hook = "clam" + expected = "projects/{project}/locations/{location}/repositories/{repository}/hooks/{hook}".format( + project=project, + location=location, + repository=repository, + hook=hook, + ) + actual = SecureSourceManagerClient.hook_path(project, location, repository, hook) + assert expected == actual + + +def test_parse_hook_path(): + expected = { + "project": "whelk", + "location": "octopus", + "repository": "oyster", + "hook": "nudibranch", + } + path = SecureSourceManagerClient.hook_path(**expected) + + # Check that the path construction is reversible. + actual = SecureSourceManagerClient.parse_hook_path(path) + assert expected == actual + + +def test_instance_path(): + project = "cuttlefish" + location = "mussel" + instance = "winkle" expected = "projects/{project}/locations/{location}/instances/{instance}".format( project=project, location=location, @@ -15619,9 +44768,9 @@ def test_instance_path(): def test_parse_instance_path(): expected = { - "project": "clam", - "location": "whelk", - "instance": "octopus", + "project": "nautilus", + "location": "scallop", + "instance": "abalone", } path = SecureSourceManagerClient.instance_path(**expected) @@ -15630,10 +44779,138 @@ def test_parse_instance_path(): assert expected == actual +def test_issue_path(): + project = "squid" + location = "clam" + repository = "whelk" + issue = "octopus" + expected = "projects/{project}/locations/{location}/repositories/{repository}/issues/{issue}".format( + project=project, + location=location, + repository=repository, + issue=issue, + ) + actual = SecureSourceManagerClient.issue_path(project, location, repository, issue) + assert expected == actual + + +def test_parse_issue_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "repository": "cuttlefish", + "issue": "mussel", + } + path = SecureSourceManagerClient.issue_path(**expected) + + # Check that the path construction is reversible. + actual = SecureSourceManagerClient.parse_issue_path(path) + assert expected == actual + + +def test_issue_comment_path(): + project = "winkle" + location = "nautilus" + repository = "scallop" + issue = "abalone" + comment = "squid" + expected = "projects/{project}/locations/{location}/repositories/{repository}/issues/{issue}/issueComments/{comment}".format( + project=project, + location=location, + repository=repository, + issue=issue, + comment=comment, + ) + actual = SecureSourceManagerClient.issue_comment_path( + project, location, repository, issue, comment + ) + assert expected == actual + + +def test_parse_issue_comment_path(): + expected = { + "project": "clam", + "location": "whelk", + "repository": "octopus", + "issue": "oyster", + "comment": "nudibranch", + } + path = SecureSourceManagerClient.issue_comment_path(**expected) + + # Check that the path construction is reversible. + actual = SecureSourceManagerClient.parse_issue_comment_path(path) + assert expected == actual + + +def test_pull_request_path(): + project = "cuttlefish" + location = "mussel" + repository = "winkle" + pull_request = "nautilus" + expected = "projects/{project}/locations/{location}/repositories/{repository}/pullRequests/{pull_request}".format( + project=project, + location=location, + repository=repository, + pull_request=pull_request, + ) + actual = SecureSourceManagerClient.pull_request_path( + project, location, repository, pull_request + ) + assert expected == actual + + +def test_parse_pull_request_path(): + expected = { + "project": "scallop", + "location": "abalone", + "repository": "squid", + "pull_request": "clam", + } + path = SecureSourceManagerClient.pull_request_path(**expected) + + # Check that the path construction is reversible. + actual = SecureSourceManagerClient.parse_pull_request_path(path) + assert expected == actual + + +def test_pull_request_comment_path(): + project = "whelk" + location = "octopus" + repository = "oyster" + pull_request = "nudibranch" + comment = "cuttlefish" + expected = "projects/{project}/locations/{location}/repositories/{repository}/pullRequests/{pull_request}/pullRequestComments/{comment}".format( + project=project, + location=location, + repository=repository, + pull_request=pull_request, + comment=comment, + ) + actual = SecureSourceManagerClient.pull_request_comment_path( + project, location, repository, pull_request, comment + ) + assert expected == actual + + +def test_parse_pull_request_comment_path(): + expected = { + "project": "mussel", + "location": "winkle", + "repository": "nautilus", + "pull_request": "scallop", + "comment": "abalone", + } + path = SecureSourceManagerClient.pull_request_comment_path(**expected) + + # Check that the path construction is reversible. + actual = SecureSourceManagerClient.parse_pull_request_comment_path(path) + assert expected == actual + + def test_repository_path(): - project = "oyster" - location = "nudibranch" - repository = "cuttlefish" + project = "squid" + location = "clam" + repository = "whelk" expected = ( "projects/{project}/locations/{location}/repositories/{repository}".format( project=project, @@ -15647,9 +44924,9 @@ def test_repository_path(): def test_parse_repository_path(): expected = { - "project": "mussel", - "location": "winkle", - "repository": "nautilus", + "project": "octopus", + "location": "oyster", + "repository": "nudibranch", } path = SecureSourceManagerClient.repository_path(**expected) @@ -15659,9 +44936,9 @@ def test_parse_repository_path(): def test_service_attachment_path(): - project = "scallop" - region = "abalone" - service_attachment = "squid" + project = "cuttlefish" + region = "mussel" + service_attachment = "winkle" expected = "projects/{project}/regions/{region}/serviceAttachments/{service_attachment}".format( project=project, region=region, @@ -15675,9 +44952,9 @@ def test_service_attachment_path(): def test_parse_service_attachment_path(): expected = { - "project": "clam", - "region": "whelk", - "service_attachment": "octopus", + "project": "nautilus", + "region": "scallop", + "service_attachment": "abalone", } path = SecureSourceManagerClient.service_attachment_path(**expected) @@ -15687,7 +44964,7 @@ def test_parse_service_attachment_path(): def test_common_billing_account_path(): - billing_account = "oyster" + billing_account = "squid" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -15697,7 +44974,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nudibranch", + "billing_account": "clam", } path = SecureSourceManagerClient.common_billing_account_path(**expected) @@ -15707,7 +44984,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "cuttlefish" + folder = "whelk" expected = "folders/{folder}".format( folder=folder, ) @@ -15717,7 +44994,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "mussel", + "folder": "octopus", } path = SecureSourceManagerClient.common_folder_path(**expected) @@ -15727,7 +45004,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "winkle" + organization = "oyster" expected = "organizations/{organization}".format( organization=organization, ) @@ -15737,7 +45014,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nautilus", + "organization": "nudibranch", } path = SecureSourceManagerClient.common_organization_path(**expected) @@ -15747,7 +45024,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "scallop" + project = "cuttlefish" expected = "projects/{project}".format( project=project, ) @@ -15757,7 +45034,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "abalone", + "project": "mussel", } path = SecureSourceManagerClient.common_project_path(**expected) @@ -15767,8 +45044,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "squid" - location = "clam" + project = "winkle" + location = "nautilus" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -15779,8 +45056,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "whelk", - "location": "octopus", + "project": "scallop", + "location": "abalone", } path = SecureSourceManagerClient.common_location_path(**expected)