From 9453ab3d7d836f2fce8d957b9b49fe1073945a27 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Thu, 9 Mar 2023 12:28:37 -0600 Subject: [PATCH] feat(Build): introduce cloudbuild v2 (#5924) --- Build/.OwlBot.yaml | 4 +- Build/metadata/V2/Cloudbuild.php | 53 + Build/metadata/V2/Repositories.php | Bin 0 -> 9735 bytes .../batch_create_repositories.php | 121 ++ .../create_connection.php | 91 + .../create_repository.php | 102 ++ .../delete_connection.php | 76 + .../delete_repository.php | 81 + .../fetch_linkable_repositories.php | 77 + .../fetch_read_token.php | 72 + .../fetch_read_write_token.php | 72 + .../get_connection.php | 67 + .../get_iam_policy.php | 67 + .../get_repository.php | 72 + .../list_connections.php | 72 + .../list_repositories.php | 76 + .../set_iam_policy.php | 73 + .../test_iam_permissions.php | 80 + .../update_connection.php | 68 + .../src/V2/BatchCreateRepositoriesRequest.php | 113 ++ .../V2/BatchCreateRepositoriesResponse.php | 67 + Build/src/V2/Connection.php | 435 +++++ Build/src/V2/CreateConnectionRequest.php | 161 ++ Build/src/V2/CreateRepositoryRequest.php | 165 ++ Build/src/V2/DeleteConnectionRequest.php | 147 ++ Build/src/V2/DeleteRepositoryRequest.php | 147 ++ .../V2/FetchLinkableRepositoriesRequest.php | 139 ++ .../V2/FetchLinkableRepositoriesResponse.php | 101 ++ Build/src/V2/FetchReadTokenRequest.php | 71 + Build/src/V2/FetchReadTokenResponse.php | 111 ++ Build/src/V2/FetchReadWriteTokenRequest.php | 71 + Build/src/V2/FetchReadWriteTokenResponse.php | 111 ++ .../V2/Gapic/RepositoryManagerGapicClient.php | 1392 ++++++++++++++++ Build/src/V2/GetConnectionRequest.php | 71 + Build/src/V2/GetRepositoryRequest.php | 71 + Build/src/V2/GitHubConfig.php | 119 ++ Build/src/V2/GitHubEnterpriseConfig.php | 407 +++++ Build/src/V2/InstallationState.php | 145 ++ Build/src/V2/InstallationState/Stage.php | 77 + Build/src/V2/ListConnectionsRequest.php | 139 ++ Build/src/V2/ListConnectionsResponse.php | 101 ++ Build/src/V2/ListRepositoriesRequest.php | 185 +++ Build/src/V2/ListRepositoriesResponse.php | 101 ++ Build/src/V2/OAuthCredential.php | 106 ++ Build/src/V2/OperationMetadata.php | 307 ++++ Build/src/V2/Repository.php | 269 +++ Build/src/V2/RepositoryManagerClient.php | 34 + .../V2/RunWorkflowCustomOperationMetadata.php | 307 ++++ Build/src/V2/ServiceDirectoryConfig.php | 76 + Build/src/V2/UpdateConnectionRequest.php | 213 +++ Build/src/V2/gapic_metadata.json | 98 ++ .../repository_manager_client_config.json | 124 ++ .../repository_manager_descriptor_config.php | 98 ++ .../repository_manager_rest_client_config.php | 227 +++ .../Unit/V2/RepositoryManagerClientTest.php | 1467 +++++++++++++++++ 55 files changed, 9295 insertions(+), 2 deletions(-) create mode 100644 Build/metadata/V2/Cloudbuild.php create mode 100644 Build/metadata/V2/Repositories.php create mode 100644 Build/samples/V2/RepositoryManagerClient/batch_create_repositories.php create mode 100644 Build/samples/V2/RepositoryManagerClient/create_connection.php create mode 100644 Build/samples/V2/RepositoryManagerClient/create_repository.php create mode 100644 Build/samples/V2/RepositoryManagerClient/delete_connection.php create mode 100644 Build/samples/V2/RepositoryManagerClient/delete_repository.php create mode 100644 Build/samples/V2/RepositoryManagerClient/fetch_linkable_repositories.php create mode 100644 Build/samples/V2/RepositoryManagerClient/fetch_read_token.php create mode 100644 Build/samples/V2/RepositoryManagerClient/fetch_read_write_token.php create mode 100644 Build/samples/V2/RepositoryManagerClient/get_connection.php create mode 100644 Build/samples/V2/RepositoryManagerClient/get_iam_policy.php create mode 100644 Build/samples/V2/RepositoryManagerClient/get_repository.php create mode 100644 Build/samples/V2/RepositoryManagerClient/list_connections.php create mode 100644 Build/samples/V2/RepositoryManagerClient/list_repositories.php create mode 100644 Build/samples/V2/RepositoryManagerClient/set_iam_policy.php create mode 100644 Build/samples/V2/RepositoryManagerClient/test_iam_permissions.php create mode 100644 Build/samples/V2/RepositoryManagerClient/update_connection.php create mode 100644 Build/src/V2/BatchCreateRepositoriesRequest.php create mode 100644 Build/src/V2/BatchCreateRepositoriesResponse.php create mode 100644 Build/src/V2/Connection.php create mode 100644 Build/src/V2/CreateConnectionRequest.php create mode 100644 Build/src/V2/CreateRepositoryRequest.php create mode 100644 Build/src/V2/DeleteConnectionRequest.php create mode 100644 Build/src/V2/DeleteRepositoryRequest.php create mode 100644 Build/src/V2/FetchLinkableRepositoriesRequest.php create mode 100644 Build/src/V2/FetchLinkableRepositoriesResponse.php create mode 100644 Build/src/V2/FetchReadTokenRequest.php create mode 100644 Build/src/V2/FetchReadTokenResponse.php create mode 100644 Build/src/V2/FetchReadWriteTokenRequest.php create mode 100644 Build/src/V2/FetchReadWriteTokenResponse.php create mode 100644 Build/src/V2/Gapic/RepositoryManagerGapicClient.php create mode 100644 Build/src/V2/GetConnectionRequest.php create mode 100644 Build/src/V2/GetRepositoryRequest.php create mode 100644 Build/src/V2/GitHubConfig.php create mode 100644 Build/src/V2/GitHubEnterpriseConfig.php create mode 100644 Build/src/V2/InstallationState.php create mode 100644 Build/src/V2/InstallationState/Stage.php create mode 100644 Build/src/V2/ListConnectionsRequest.php create mode 100644 Build/src/V2/ListConnectionsResponse.php create mode 100644 Build/src/V2/ListRepositoriesRequest.php create mode 100644 Build/src/V2/ListRepositoriesResponse.php create mode 100644 Build/src/V2/OAuthCredential.php create mode 100644 Build/src/V2/OperationMetadata.php create mode 100644 Build/src/V2/Repository.php create mode 100644 Build/src/V2/RepositoryManagerClient.php create mode 100644 Build/src/V2/RunWorkflowCustomOperationMetadata.php create mode 100644 Build/src/V2/ServiceDirectoryConfig.php create mode 100644 Build/src/V2/UpdateConnectionRequest.php create mode 100644 Build/src/V2/gapic_metadata.json create mode 100644 Build/src/V2/resources/repository_manager_client_config.json create mode 100644 Build/src/V2/resources/repository_manager_descriptor_config.php create mode 100644 Build/src/V2/resources/repository_manager_rest_client_config.php create mode 100644 Build/tests/Unit/V2/RepositoryManagerClientTest.php diff --git a/Build/.OwlBot.yaml b/Build/.OwlBot.yaml index 6eb07c36801..8d979b80a8f 100644 --- a/Build/.OwlBot.yaml +++ b/Build/.OwlBot.yaml @@ -1,4 +1,4 @@ deep-copy-regex: - - source: /google/devtools/cloudbuild/v1/.*-php/(.*) - dest: /owl-bot-staging/Build/v1/$1 + - source: /google/devtools/cloudbuild/(v1|v2)/.*-php/(.*) + dest: /owl-bot-staging/Build/$1/$2 api-name: Build diff --git a/Build/metadata/V2/Cloudbuild.php b/Build/metadata/V2/Cloudbuild.php new file mode 100644 index 00000000000..5cdbf022094 --- /dev/null +++ b/Build/metadata/V2/Cloudbuild.php @@ -0,0 +1,53 @@ +internalAddGeneratedFile( + ' +™ +.google/devtools/cloudbuild/v2/cloudbuild.protogoogle.devtools.cloudbuild.v2google/api/client.protogoogle/api/field_behavior.protogoogle/api/resource.protogoogle/protobuf/timestamp.proto"€ +OperationMetadata4 + create_time ( 2.google.protobuf.TimestampBàA1 +end_time ( 2.google.protobuf.TimestampBàA +target ( BàA +verb ( BàA +status_message ( BàA# +requested_cancellation (BàA + api_version ( BàA"’ +"RunWorkflowCustomOperationMetadata4 + create_time ( 2.google.protobuf.TimestampBàA1 +end_time ( 2.google.protobuf.TimestampBàA +verb ( BàA# +requested_cancellation (BàA + api_version ( BàA +target ( BàA +pipeline_run_id ( BàAB± +google.devtools.cloudbuild.v2BCloudBuildProtoPZGgoogle.golang.org/genproto/googleapis/devtools/cloudbuild/v2;cloudbuild¢GCBªGoogle.Cloud.CloudBuild.V2ÊGoogle\\Cloud\\Build\\V2êGoogle::Cloud::Build::V2êAN +compute.googleapis.com/Network,projects/{project}/global/networks/{network}êAY +!iam.googleapis.com/ServiceAccount4projects/{project}/serviceAccounts/{service_account}êAJ +#secretmanager.googleapis.com/Secret#projects/{project}/secrets/{secret}êAd +*secretmanager.googleapis.com/SecretVersion6projects/{project}/secrets/{secret}/versions/{version}êA| +0cloudbuild.googleapis.com/githubEnterpriseConfigHprojects/{project}/locations/{location}/githubEnterpriseConfigs/{config}bproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/Build/metadata/V2/Repositories.php b/Build/metadata/V2/Repositories.php new file mode 100644 index 0000000000000000000000000000000000000000..d479309e7f2a0df715d6e06f3aa9d6123e1a65c3 GIT binary patch literal 9735 zcmb_iOKcoj6`k&m6Z<)i?U#w&=_pK1O+*so>7MBfzse+W+3wgL*|B3gi4wJ@Ro(sE zE>f*=y?fvNo_pWt{af~~joy-$h)EpHBXy~IAbGn)vK`B_YL+2Yn>#zik!seStsBJ2 zOVZ-HbZ32ADlM*TzX_zS)pTk^ks6lOFi4?J_C3oo+(ON;n)PZ^H|mA`V!>U`8DEcbu>QSd1*1boW(i`NmV8Jg=#n-PBK8Is_i z-K-jVO>#ZWga0n+ZbdhBPuC3nDd=@W+R+S`0E6zaJ596Z>6R%`f_1Y-u3VKkPdfIJ z4f+7RFWCk)4Vb08VtT|eH3MXIYmRP%b{jBMQ5wVx3`*Zzxhkfm?DQS!3YSq)x`ezT zc}|l=XO|?0cumK=&g7;HTESDfhuu_LFRP|$Q7c%ct0mf3Kcrm35a^14j}eK6Am9tV4u_H1tefdf)z zrZvrdoLt#}c3X!;@w7d=H!Ta$w{Pkq9MyU~h`!s9vsZ$6q0w_0{dobsGib8ni<~0w zr*}R~@BDr-H!T=ywhoC;gNP@2?v2QY9U3W>st6S^;Cy7ju84;opB&+I@#!r=WrUtB zSb=B7pbKJk)GTvHZ)ArU-BwC@Z*t4~b(tx=Vb9CmF-9CSq6$ zr~}q_5!OuzW5ZziSD_$CvZoo-cVd{XLO{ADFePxV&(6YSKZ_>A7sBE4chhLH%kuaGGz6|| z@IXIP{923&yBOrbfeqon*U>3}HkWc^X5p@yMo42hRcSgp%NmwX8M%pu7%@JFCbzcL zrBdbIovn@1!piNH(&EHxcnaZ-(w)VXJ4=;?&62uZs;C{TMuGY`p6(dj5=;5BqkYkIrT**zsr1>mj@$N^m!Gr?#v zA2a2;3d9Qm6~2JZYPJon8^oB86ndSRBP0JlgQoc8o%jL~F}!QJ9*dX&fzucQ43eor z(~u$!i=#9?gHEzZ1YZm|LVvqPv%zp=1aF}nVBbCkVW6$J1Qhcs`^0gfb;wdk9+@wE zq0XWi{%KD$!F7&MHpt&CMt7f+;rr;~6H?u^tj9jX4!#t!Ux9BQn~eas41R#JE^+qt z8mZKEz((j&4}3&NFk-YAhv-|Je9@;~V8wzO(RGbVP0Nl_vB7g^=tK|%zL_Zcip+h4 zruwj%L#Kp%B54XNX|AI3W$```yW6@{uSsHweu@gpr1hn`thL^D4ZWZI%)-KTLl)LIsO{%pf%Hm zRz+}@SS}twaRS5}?}Q1+Pm97%g(0J#PJZBV02nww0YjP)bF7OCVgyhpg{A?a01F`U zMQQa>|9y1Q)*L{*cErcYYWjRz&7f1pV{|A3EtYAVLt|mxsQ^^cE|cS&yop|4B3?-0 zORcoEssmLiaK_ZC?naopKG&n!B4PD&&~(@IqUPO%ZaZ+0o3P}C#_3=3eggq;k9FkX zXkY1e7t+8R+=Ydp;it+y^a#D{&W<56G@4LiJLbU}RDmBn??9g-XfIhZbT6}{0{++*qm1&joy@CCpF zhf&Bv{vqTPP2}KJynzn`)qu?btizME(X@Tp(G6JR@@`J{P_|p1W3pg>XbF-uRKO3j zBUm?Cl75JCY$35pwE6=__sBL~W%$#>dd3N=aC>z-ELB52~!z?X}FbUZ`vb5dSHK#ygr69Jk2o81G9R=ld=)9-{JGn+nN&`$84{ zEdCTiv9sxk4aH6ZUyYbh`~?ri<)XquF$|@Aa^ts0cwp+t zz_t~p5-DIIPK8BnHhlDPDx%!LCi-0(P4{WV@QoP6>O+?>Q2xLTwl05gM1xhs##c$r zyimslwmYI>eXefCx0?eS?vEVcBeqWf@Zo6RNO1rkQpjrz9p^9)u*4YC7F~r9@Bap% z(Ahi2CPycMug2G7LZzEdK>m80QinqRVObMafKMRjIdp}li&d+Wz*j4#0({0pcy8u+ zTymVy_rDZ6+oK!A-;8lo4;tSXamP+QNrjs~Vs8FWe#mm&30m|-ElOtuD_X4v=P&Im z0G9d@?8N_0p)-L}=Dhm6gDDX-BcJdPnd^cED#T?$!TEy-|!P#x_+$xBZ5O^t` mTGf-x7}qWbw>xI}-J!@;BRE2Xt57|z8L^T4I#3I>5c)q0%qFz} literal 0 HcmV?d00001 diff --git a/Build/samples/V2/RepositoryManagerClient/batch_create_repositories.php b/Build/samples/V2/RepositoryManagerClient/batch_create_repositories.php new file mode 100644 index 00000000000..75c1b5969e6 --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/batch_create_repositories.php @@ -0,0 +1,121 @@ +setRemoteUri($requestsRepositoryRemoteUri); + $createRepositoryRequest = (new CreateRepositoryRequest()) + ->setParent($formattedRequestsParent) + ->setRepository($requestsRepository) + ->setRepositoryId($requestsRepositoryId); + $requests = [$createRepositoryRequest,]; + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $repositoryManagerClient->batchCreateRepositories($formattedParent, $requests); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var BatchCreateRepositoriesResponse $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = RepositoryManagerClient::connectionName( + '[PROJECT]', + '[LOCATION]', + '[CONNECTION]' + ); + $formattedRequestsParent = RepositoryManagerClient::connectionName( + '[PROJECT]', + '[LOCATION]', + '[CONNECTION]' + ); + $requestsRepositoryRemoteUri = '[REMOTE_URI]'; + $requestsRepositoryId = '[REPOSITORY_ID]'; + + batch_create_repositories_sample( + $formattedParent, + $formattedRequestsParent, + $requestsRepositoryRemoteUri, + $requestsRepositoryId + ); +} +// [END cloudbuild_v2_generated_RepositoryManager_BatchCreateRepositories_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/create_connection.php b/Build/samples/V2/RepositoryManagerClient/create_connection.php new file mode 100644 index 00000000000..8a1b5e8e93f --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/create_connection.php @@ -0,0 +1,91 @@ +createConnection( + $formattedParent, + $connection, + $connectionId + ); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Connection $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = RepositoryManagerClient::locationName('[PROJECT]', '[LOCATION]'); + $connectionId = '[CONNECTION_ID]'; + + create_connection_sample($formattedParent, $connectionId); +} +// [END cloudbuild_v2_generated_RepositoryManager_CreateConnection_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/create_repository.php b/Build/samples/V2/RepositoryManagerClient/create_repository.php new file mode 100644 index 00000000000..0942338e419 --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/create_repository.php @@ -0,0 +1,102 @@ +setRemoteUri($repositoryRemoteUri); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $repositoryManagerClient->createRepository( + $formattedParent, + $repository, + $repositoryId + ); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Repository $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = RepositoryManagerClient::connectionName( + '[PROJECT]', + '[LOCATION]', + '[CONNECTION]' + ); + $repositoryRemoteUri = '[REMOTE_URI]'; + $repositoryId = '[REPOSITORY_ID]'; + + create_repository_sample($formattedParent, $repositoryRemoteUri, $repositoryId); +} +// [END cloudbuild_v2_generated_RepositoryManager_CreateRepository_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/delete_connection.php b/Build/samples/V2/RepositoryManagerClient/delete_connection.php new file mode 100644 index 00000000000..1d8a5eb974f --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/delete_connection.php @@ -0,0 +1,76 @@ +deleteConnection($formattedName); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + printf('Operation completed successfully.' . PHP_EOL); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = RepositoryManagerClient::connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + + delete_connection_sample($formattedName); +} +// [END cloudbuild_v2_generated_RepositoryManager_DeleteConnection_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/delete_repository.php b/Build/samples/V2/RepositoryManagerClient/delete_repository.php new file mode 100644 index 00000000000..cf5a22b4db1 --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/delete_repository.php @@ -0,0 +1,81 @@ +deleteRepository($formattedName); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + printf('Operation completed successfully.' . PHP_EOL); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = RepositoryManagerClient::repositoryName( + '[PROJECT]', + '[LOCATION]', + '[CONNECTION]', + '[REPOSITORY]' + ); + + delete_repository_sample($formattedName); +} +// [END cloudbuild_v2_generated_RepositoryManager_DeleteRepository_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/fetch_linkable_repositories.php b/Build/samples/V2/RepositoryManagerClient/fetch_linkable_repositories.php new file mode 100644 index 00000000000..54e60c1b4b3 --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/fetch_linkable_repositories.php @@ -0,0 +1,77 @@ +fetchLinkableRepositories($formattedConnection); + + /** @var Repository $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedConnection = RepositoryManagerClient::connectionName( + '[PROJECT]', + '[LOCATION]', + '[CONNECTION]' + ); + + fetch_linkable_repositories_sample($formattedConnection); +} +// [END cloudbuild_v2_generated_RepositoryManager_FetchLinkableRepositories_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/fetch_read_token.php b/Build/samples/V2/RepositoryManagerClient/fetch_read_token.php new file mode 100644 index 00000000000..f57da799894 --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/fetch_read_token.php @@ -0,0 +1,72 @@ +fetchReadToken($formattedRepository); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedRepository = RepositoryManagerClient::repositoryName( + '[PROJECT]', + '[LOCATION]', + '[CONNECTION]', + '[REPOSITORY]' + ); + + fetch_read_token_sample($formattedRepository); +} +// [END cloudbuild_v2_generated_RepositoryManager_FetchReadToken_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/fetch_read_write_token.php b/Build/samples/V2/RepositoryManagerClient/fetch_read_write_token.php new file mode 100644 index 00000000000..51ca8ba3057 --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/fetch_read_write_token.php @@ -0,0 +1,72 @@ +fetchReadWriteToken($formattedRepository); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedRepository = RepositoryManagerClient::repositoryName( + '[PROJECT]', + '[LOCATION]', + '[CONNECTION]', + '[REPOSITORY]' + ); + + fetch_read_write_token_sample($formattedRepository); +} +// [END cloudbuild_v2_generated_RepositoryManager_FetchReadWriteToken_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/get_connection.php b/Build/samples/V2/RepositoryManagerClient/get_connection.php new file mode 100644 index 00000000000..89ca0b8b141 --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/get_connection.php @@ -0,0 +1,67 @@ +getConnection($formattedName); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = RepositoryManagerClient::connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + + get_connection_sample($formattedName); +} +// [END cloudbuild_v2_generated_RepositoryManager_GetConnection_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/get_iam_policy.php b/Build/samples/V2/RepositoryManagerClient/get_iam_policy.php new file mode 100644 index 00000000000..55f48a299d5 --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/get_iam_policy.php @@ -0,0 +1,67 @@ +getIamPolicy($resource); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $resource = '[RESOURCE]'; + + get_iam_policy_sample($resource); +} +// [END cloudbuild_v2_generated_RepositoryManager_GetIamPolicy_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/get_repository.php b/Build/samples/V2/RepositoryManagerClient/get_repository.php new file mode 100644 index 00000000000..fb7c68caef0 --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/get_repository.php @@ -0,0 +1,72 @@ +getRepository($formattedName); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = RepositoryManagerClient::repositoryName( + '[PROJECT]', + '[LOCATION]', + '[CONNECTION]', + '[REPOSITORY]' + ); + + get_repository_sample($formattedName); +} +// [END cloudbuild_v2_generated_RepositoryManager_GetRepository_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/list_connections.php b/Build/samples/V2/RepositoryManagerClient/list_connections.php new file mode 100644 index 00000000000..00a8f81a86f --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/list_connections.php @@ -0,0 +1,72 @@ +listConnections($formattedParent); + + /** @var Connection $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = RepositoryManagerClient::locationName('[PROJECT]', '[LOCATION]'); + + list_connections_sample($formattedParent); +} +// [END cloudbuild_v2_generated_RepositoryManager_ListConnections_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/list_repositories.php b/Build/samples/V2/RepositoryManagerClient/list_repositories.php new file mode 100644 index 00000000000..c78f520f6f8 --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/list_repositories.php @@ -0,0 +1,76 @@ +listRepositories($formattedParent); + + /** @var Repository $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = RepositoryManagerClient::connectionName( + '[PROJECT]', + '[LOCATION]', + '[CONNECTION]' + ); + + list_repositories_sample($formattedParent); +} +// [END cloudbuild_v2_generated_RepositoryManager_ListRepositories_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/set_iam_policy.php b/Build/samples/V2/RepositoryManagerClient/set_iam_policy.php new file mode 100644 index 00000000000..9118eede460 --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/set_iam_policy.php @@ -0,0 +1,73 @@ +setIamPolicy($resource, $policy); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $resource = '[RESOURCE]'; + + set_iam_policy_sample($resource); +} +// [END cloudbuild_v2_generated_RepositoryManager_SetIamPolicy_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/test_iam_permissions.php b/Build/samples/V2/RepositoryManagerClient/test_iam_permissions.php new file mode 100644 index 00000000000..63ba941a5d8 --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/test_iam_permissions.php @@ -0,0 +1,80 @@ +testIamPermissions($resource, $permissions); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $resource = '[RESOURCE]'; + $permissionsElement = '[PERMISSIONS]'; + + test_iam_permissions_sample($resource, $permissionsElement); +} +// [END cloudbuild_v2_generated_RepositoryManager_TestIamPermissions_sync] diff --git a/Build/samples/V2/RepositoryManagerClient/update_connection.php b/Build/samples/V2/RepositoryManagerClient/update_connection.php new file mode 100644 index 00000000000..0ac518be7fa --- /dev/null +++ b/Build/samples/V2/RepositoryManagerClient/update_connection.php @@ -0,0 +1,68 @@ +updateConnection($connection); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var Connection $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END cloudbuild_v2_generated_RepositoryManager_UpdateConnection_sync] diff --git a/Build/src/V2/BatchCreateRepositoriesRequest.php b/Build/src/V2/BatchCreateRepositoriesRequest.php new file mode 100644 index 00000000000..10792323370 --- /dev/null +++ b/Build/src/V2/BatchCreateRepositoriesRequest.php @@ -0,0 +1,113 @@ +google.devtools.cloudbuild.v2.BatchCreateRepositoriesRequest + */ +class BatchCreateRepositoriesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The connection to contain all the repositories being created. + * Format: projects/*/locations/*/connections/* + * The parent field in the CreateRepositoryRequest messages + * must either be empty or match this field. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Required. The request messages specifying the repositories to create. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.CreateRepositoryRequest requests = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $requests; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The connection to contain all the repositories being created. + * Format: projects/*/locations/*/connections/* + * The parent field in the CreateRepositoryRequest messages + * must either be empty or match this field. + * @type array<\Google\Cloud\Build\V2\CreateRepositoryRequest>|\Google\Protobuf\Internal\RepeatedField $requests + * Required. The request messages specifying the repositories to create. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The connection to contain all the repositories being created. + * Format: projects/*/locations/*/connections/* + * The parent field in the CreateRepositoryRequest messages + * must either be empty or match this field. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The connection to contain all the repositories being created. + * Format: projects/*/locations/*/connections/* + * The parent field in the CreateRepositoryRequest messages + * must either be empty or match this field. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The request messages specifying the repositories to create. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.CreateRepositoryRequest requests = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getRequests() + { + return $this->requests; + } + + /** + * Required. The request messages specifying the repositories to create. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.CreateRepositoryRequest requests = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param array<\Google\Cloud\Build\V2\CreateRepositoryRequest>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setRequests($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Build\V2\CreateRepositoryRequest::class); + $this->requests = $arr; + + return $this; + } + +} + diff --git a/Build/src/V2/BatchCreateRepositoriesResponse.php b/Build/src/V2/BatchCreateRepositoriesResponse.php new file mode 100644 index 00000000000..4aec29b05e2 --- /dev/null +++ b/Build/src/V2/BatchCreateRepositoriesResponse.php @@ -0,0 +1,67 @@ +google.devtools.cloudbuild.v2.BatchCreateRepositoriesResponse + */ +class BatchCreateRepositoriesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Repository resources created. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.Repository repositories = 1; + */ + private $repositories; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Build\V2\Repository>|\Google\Protobuf\Internal\RepeatedField $repositories + * Repository resources created. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Repository resources created. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.Repository repositories = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getRepositories() + { + return $this->repositories; + } + + /** + * Repository resources created. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.Repository repositories = 1; + * @param array<\Google\Cloud\Build\V2\Repository>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setRepositories($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Build\V2\Repository::class); + $this->repositories = $arr; + + return $this; + } + +} + diff --git a/Build/src/V2/Connection.php b/Build/src/V2/Connection.php new file mode 100644 index 00000000000..902ee97efb2 --- /dev/null +++ b/Build/src/V2/Connection.php @@ -0,0 +1,435 @@ +google.devtools.cloudbuild.v2.Connection + */ +class Connection extends \Google\Protobuf\Internal\Message +{ + /** + * Immutable. The resource name of the connection, in the format + * `projects/{project}/locations/{location}/connections/{connection_id}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + */ + private $name = ''; + /** + * Output only. Server assigned timestamp for when the connection was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $create_time = null; + /** + * Output only. Server assigned timestamp for when the connection was updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $update_time = null; + /** + * Output only. Installation state of the Connection. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.InstallationState installation_state = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $installation_state = null; + /** + * If disabled is set to true, functionality is disabled for this connection. + * Repository based API methods and webhooks processing for repositories in + * this connection will be disabled. + * + * Generated from protobuf field bool disabled = 13; + */ + private $disabled = false; + /** + * Output only. Set to true when the connection is being set up or updated in + * the background. + * + * Generated from protobuf field bool reconciling = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $reconciling = false; + /** + * Allows clients to store small amounts of arbitrary data. + * + * Generated from protobuf field map annotations = 15; + */ + private $annotations; + /** + * 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. + * + * Generated from protobuf field string etag = 16; + */ + private $etag = ''; + protected $connection_config; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Immutable. The resource name of the connection, in the format + * `projects/{project}/locations/{location}/connections/{connection_id}`. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. Server assigned timestamp for when the connection was created. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. Server assigned timestamp for when the connection was updated. + * @type \Google\Cloud\Build\V2\GitHubConfig $github_config + * Configuration for connections to github.com. + * @type \Google\Cloud\Build\V2\GitHubEnterpriseConfig $github_enterprise_config + * Configuration for connections to an instance of GitHub Enterprise. + * @type \Google\Cloud\Build\V2\InstallationState $installation_state + * Output only. Installation state of the Connection. + * @type bool $disabled + * If disabled is set to true, functionality is disabled for this connection. + * Repository based API methods and webhooks processing for repositories in + * this connection will be disabled. + * @type bool $reconciling + * Output only. Set to true when the connection is being set up or updated in + * the background. + * @type array|\Google\Protobuf\Internal\MapField $annotations + * Allows clients to store small amounts of arbitrary data. + * @type string $etag + * 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. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Immutable. The resource name of the connection, in the format + * `projects/{project}/locations/{location}/connections/{connection_id}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Immutable. The resource name of the connection, in the format + * `projects/{project}/locations/{location}/connections/{connection_id}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Output only. Server assigned timestamp for when the connection was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. Server assigned timestamp for when the connection was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. Server assigned timestamp for when the connection was updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + + /** + * Output only. Server assigned timestamp for when the connection was updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Configuration for connections to github.com. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.GitHubConfig github_config = 5; + * @return \Google\Cloud\Build\V2\GitHubConfig|null + */ + public function getGithubConfig() + { + return $this->readOneof(5); + } + + public function hasGithubConfig() + { + return $this->hasOneof(5); + } + + /** + * Configuration for connections to github.com. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.GitHubConfig github_config = 5; + * @param \Google\Cloud\Build\V2\GitHubConfig $var + * @return $this + */ + public function setGithubConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Build\V2\GitHubConfig::class); + $this->writeOneof(5, $var); + + return $this; + } + + /** + * Configuration for connections to an instance of GitHub Enterprise. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.GitHubEnterpriseConfig github_enterprise_config = 6; + * @return \Google\Cloud\Build\V2\GitHubEnterpriseConfig|null + */ + public function getGithubEnterpriseConfig() + { + return $this->readOneof(6); + } + + public function hasGithubEnterpriseConfig() + { + return $this->hasOneof(6); + } + + /** + * Configuration for connections to an instance of GitHub Enterprise. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.GitHubEnterpriseConfig github_enterprise_config = 6; + * @param \Google\Cloud\Build\V2\GitHubEnterpriseConfig $var + * @return $this + */ + public function setGithubEnterpriseConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Build\V2\GitHubEnterpriseConfig::class); + $this->writeOneof(6, $var); + + return $this; + } + + /** + * Output only. Installation state of the Connection. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.InstallationState installation_state = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\Build\V2\InstallationState|null + */ + public function getInstallationState() + { + return $this->installation_state; + } + + public function hasInstallationState() + { + return isset($this->installation_state); + } + + public function clearInstallationState() + { + unset($this->installation_state); + } + + /** + * Output only. Installation state of the Connection. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.InstallationState installation_state = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\Build\V2\InstallationState $var + * @return $this + */ + public function setInstallationState($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Build\V2\InstallationState::class); + $this->installation_state = $var; + + return $this; + } + + /** + * If disabled is set to true, functionality is disabled for this connection. + * Repository based API methods and webhooks processing for repositories in + * this connection will be disabled. + * + * Generated from protobuf field bool disabled = 13; + * @return bool + */ + public function getDisabled() + { + return $this->disabled; + } + + /** + * If disabled is set to true, functionality is disabled for this connection. + * Repository based API methods and webhooks processing for repositories in + * this connection will be disabled. + * + * Generated from protobuf field bool disabled = 13; + * @param bool $var + * @return $this + */ + public function setDisabled($var) + { + GPBUtil::checkBool($var); + $this->disabled = $var; + + return $this; + } + + /** + * Output only. Set to true when the connection is being set up or updated in + * the background. + * + * Generated from protobuf field bool reconciling = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return bool + */ + public function getReconciling() + { + return $this->reconciling; + } + + /** + * Output only. Set to true when the connection is being set up or updated in + * the background. + * + * Generated from protobuf field bool reconciling = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param bool $var + * @return $this + */ + public function setReconciling($var) + { + GPBUtil::checkBool($var); + $this->reconciling = $var; + + return $this; + } + + /** + * Allows clients to store small amounts of arbitrary data. + * + * Generated from protobuf field map annotations = 15; + * @return \Google\Protobuf\Internal\MapField + */ + public function getAnnotations() + { + return $this->annotations; + } + + /** + * Allows clients to store small amounts of arbitrary data. + * + * Generated from protobuf field map annotations = 15; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setAnnotations($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->annotations = $arr; + + return $this; + } + + /** + * 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. + * + * Generated from protobuf field string etag = 16; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * 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. + * + * Generated from protobuf field string etag = 16; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + + /** + * @return string + */ + public function getConnectionConfig() + { + return $this->whichOneof("connection_config"); + } + +} + diff --git a/Build/src/V2/CreateConnectionRequest.php b/Build/src/V2/CreateConnectionRequest.php new file mode 100644 index 00000000000..f15b5ba8d08 --- /dev/null +++ b/Build/src/V2/CreateConnectionRequest.php @@ -0,0 +1,161 @@ +google.devtools.cloudbuild.v2.CreateConnectionRequest + */ +class CreateConnectionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Project and location where the connection will be created. + * Format: `projects/*/locations/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Required. The Connection to create. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.Connection connection = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $connection = null; + /** + * Required. The ID to use for the Connection, which will become the final + * component of the Connection's resource name. Names must be unique + * per-project per-location. Allows alphanumeric characters and any of + * -._~%!$&'()*+,;=@. + * + * Generated from protobuf field string connection_id = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + private $connection_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. Project and location where the connection will be created. + * Format: `projects/*/locations/*`. + * @type \Google\Cloud\Build\V2\Connection $connection + * Required. The Connection to create. + * @type string $connection_id + * Required. The ID to use for the Connection, which will become the final + * component of the Connection's resource name. Names must be unique + * per-project per-location. Allows alphanumeric characters and any of + * -._~%!$&'()*+,;=@. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. Project and location where the connection will be created. + * Format: `projects/*/locations/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. Project and location where the connection will be created. + * Format: `projects/*/locations/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The Connection to create. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.Connection connection = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Build\V2\Connection|null + */ + public function getConnection() + { + return $this->connection; + } + + public function hasConnection() + { + return isset($this->connection); + } + + public function clearConnection() + { + unset($this->connection); + } + + /** + * Required. The Connection to create. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.Connection connection = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Build\V2\Connection $var + * @return $this + */ + public function setConnection($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Build\V2\Connection::class); + $this->connection = $var; + + return $this; + } + + /** + * Required. The ID to use for the Connection, which will become the final + * component of the Connection's resource name. Names must be unique + * per-project per-location. Allows alphanumeric characters and any of + * -._~%!$&'()*+,;=@. + * + * Generated from protobuf field string connection_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getConnectionId() + { + return $this->connection_id; + } + + /** + * Required. The ID to use for the Connection, which will become the final + * component of the Connection's resource name. Names must be unique + * per-project per-location. Allows alphanumeric characters and any of + * -._~%!$&'()*+,;=@. + * + * Generated from protobuf field string connection_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setConnectionId($var) + { + GPBUtil::checkString($var, True); + $this->connection_id = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/CreateRepositoryRequest.php b/Build/src/V2/CreateRepositoryRequest.php new file mode 100644 index 00000000000..199eab7b863 --- /dev/null +++ b/Build/src/V2/CreateRepositoryRequest.php @@ -0,0 +1,165 @@ +google.devtools.cloudbuild.v2.CreateRepositoryRequest + */ +class CreateRepositoryRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The connection to contain the repository. If the request is part + * of a BatchCreateRepositoriesRequest, this field should be empty or match + * the parent specified there. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Required. The repository to create. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.Repository repository = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $repository = null; + /** + * Required. The ID to use for the repository, which will become the final + * component of the repository's resource name. This ID should be unique in + * the connection. Allows alphanumeric characters and any of + * -._~%!$&'()*+,;=@. + * + * Generated from protobuf field string repository_id = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + private $repository_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The connection to contain the repository. If the request is part + * of a BatchCreateRepositoriesRequest, this field should be empty or match + * the parent specified there. + * @type \Google\Cloud\Build\V2\Repository $repository + * Required. The repository to create. + * @type string $repository_id + * Required. The ID to use for the repository, which will become the final + * component of the repository's resource name. This ID should be unique in + * the connection. Allows alphanumeric characters and any of + * -._~%!$&'()*+,;=@. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The connection to contain the repository. If the request is part + * of a BatchCreateRepositoriesRequest, this field should be empty or match + * the parent specified there. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The connection to contain the repository. If the request is part + * of a BatchCreateRepositoriesRequest, this field should be empty or match + * the parent specified there. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Required. The repository to create. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.Repository repository = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Build\V2\Repository|null + */ + public function getRepository() + { + return $this->repository; + } + + public function hasRepository() + { + return isset($this->repository); + } + + public function clearRepository() + { + unset($this->repository); + } + + /** + * Required. The repository to create. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.Repository repository = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Build\V2\Repository $var + * @return $this + */ + public function setRepository($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Build\V2\Repository::class); + $this->repository = $var; + + return $this; + } + + /** + * Required. The ID to use for the repository, which will become the final + * component of the repository's resource name. This ID should be unique in + * the connection. Allows alphanumeric characters and any of + * -._~%!$&'()*+,;=@. + * + * Generated from protobuf field string repository_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getRepositoryId() + { + return $this->repository_id; + } + + /** + * Required. The ID to use for the repository, which will become the final + * component of the repository's resource name. This ID should be unique in + * the connection. Allows alphanumeric characters and any of + * -._~%!$&'()*+,;=@. + * + * Generated from protobuf field string repository_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setRepositoryId($var) + { + GPBUtil::checkString($var, True); + $this->repository_id = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/DeleteConnectionRequest.php b/Build/src/V2/DeleteConnectionRequest.php new file mode 100644 index 00000000000..4391af958c1 --- /dev/null +++ b/Build/src/V2/DeleteConnectionRequest.php @@ -0,0 +1,147 @@ +google.devtools.cloudbuild.v2.DeleteConnectionRequest + */ +class DeleteConnectionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the Connection to delete. + * Format: `projects/*/locations/*/connections/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + /** + * The current etag of the connection. + * If an etag is provided and does not match the current etag of the + * connection, deletion will be blocked and an ABORTED error will be returned. + * + * Generated from protobuf field string etag = 2; + */ + private $etag = ''; + /** + * If set, validate the request, but do not actually post it. + * + * Generated from protobuf field bool validate_only = 3; + */ + private $validate_only = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the Connection to delete. + * Format: `projects/*/locations/*/connections/*`. + * @type string $etag + * The current etag of the connection. + * If an etag is provided and does not match the current etag of the + * connection, deletion will be blocked and an ABORTED error will be returned. + * @type bool $validate_only + * If set, validate the request, but do not actually post it. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the Connection to delete. + * Format: `projects/*/locations/*/connections/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The name of the Connection to delete. + * Format: `projects/*/locations/*/connections/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The current etag of the connection. + * If an etag is provided and does not match the current etag of the + * connection, deletion will be blocked and an ABORTED error will be returned. + * + * Generated from protobuf field string etag = 2; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * The current etag of the connection. + * If an etag is provided and does not match the current etag of the + * connection, deletion will be blocked and an ABORTED error will be returned. + * + * Generated from protobuf field string etag = 2; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + + /** + * If set, validate the request, but do not actually post it. + * + * Generated from protobuf field bool validate_only = 3; + * @return bool + */ + public function getValidateOnly() + { + return $this->validate_only; + } + + /** + * If set, validate the request, but do not actually post it. + * + * Generated from protobuf field bool validate_only = 3; + * @param bool $var + * @return $this + */ + public function setValidateOnly($var) + { + GPBUtil::checkBool($var); + $this->validate_only = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/DeleteRepositoryRequest.php b/Build/src/V2/DeleteRepositoryRequest.php new file mode 100644 index 00000000000..16dd6302119 --- /dev/null +++ b/Build/src/V2/DeleteRepositoryRequest.php @@ -0,0 +1,147 @@ +google.devtools.cloudbuild.v2.DeleteRepositoryRequest + */ +class DeleteRepositoryRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the Repository to delete. + * Format: `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + /** + * The current etag of the repository. + * If an etag is provided and does not match the current etag of the + * repository, deletion will be blocked and an ABORTED error will be returned. + * + * Generated from protobuf field string etag = 2; + */ + private $etag = ''; + /** + * If set, validate the request, but do not actually post it. + * + * Generated from protobuf field bool validate_only = 3; + */ + private $validate_only = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the Repository to delete. + * Format: `projects/*/locations/*/connections/*/repositories/*`. + * @type string $etag + * The current etag of the repository. + * If an etag is provided and does not match the current etag of the + * repository, deletion will be blocked and an ABORTED error will be returned. + * @type bool $validate_only + * If set, validate the request, but do not actually post it. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the Repository to delete. + * Format: `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The name of the Repository to delete. + * Format: `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The current etag of the repository. + * If an etag is provided and does not match the current etag of the + * repository, deletion will be blocked and an ABORTED error will be returned. + * + * Generated from protobuf field string etag = 2; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * The current etag of the repository. + * If an etag is provided and does not match the current etag of the + * repository, deletion will be blocked and an ABORTED error will be returned. + * + * Generated from protobuf field string etag = 2; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + + /** + * If set, validate the request, but do not actually post it. + * + * Generated from protobuf field bool validate_only = 3; + * @return bool + */ + public function getValidateOnly() + { + return $this->validate_only; + } + + /** + * If set, validate the request, but do not actually post it. + * + * Generated from protobuf field bool validate_only = 3; + * @param bool $var + * @return $this + */ + public function setValidateOnly($var) + { + GPBUtil::checkBool($var); + $this->validate_only = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/FetchLinkableRepositoriesRequest.php b/Build/src/V2/FetchLinkableRepositoriesRequest.php new file mode 100644 index 00000000000..1fce8d912d4 --- /dev/null +++ b/Build/src/V2/FetchLinkableRepositoriesRequest.php @@ -0,0 +1,139 @@ +google.devtools.cloudbuild.v2.FetchLinkableRepositoriesRequest + */ +class FetchLinkableRepositoriesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the Connection. + * Format: `projects/*/locations/*/connections/*`. + * + * Generated from protobuf field string connection = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $connection = ''; + /** + * Number of results to return in the list. Default to 20. + * + * Generated from protobuf field int32 page_size = 2; + */ + private $page_size = 0; + /** + * Page start. + * + * Generated from protobuf field string page_token = 3; + */ + private $page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $connection + * Required. The name of the Connection. + * Format: `projects/*/locations/*/connections/*`. + * @type int $page_size + * Number of results to return in the list. Default to 20. + * @type string $page_token + * Page start. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the Connection. + * Format: `projects/*/locations/*/connections/*`. + * + * Generated from protobuf field string connection = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getConnection() + { + return $this->connection; + } + + /** + * Required. The name of the Connection. + * Format: `projects/*/locations/*/connections/*`. + * + * Generated from protobuf field string connection = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setConnection($var) + { + GPBUtil::checkString($var, True); + $this->connection = $var; + + return $this; + } + + /** + * Number of results to return in the list. Default to 20. + * + * Generated from protobuf field int32 page_size = 2; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of results to return in the list. Default to 20. + * + * Generated from protobuf field int32 page_size = 2; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Page start. + * + * Generated from protobuf field string page_token = 3; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Page start. + * + * Generated from protobuf field string page_token = 3; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/FetchLinkableRepositoriesResponse.php b/Build/src/V2/FetchLinkableRepositoriesResponse.php new file mode 100644 index 00000000000..67b41d3daa8 --- /dev/null +++ b/Build/src/V2/FetchLinkableRepositoriesResponse.php @@ -0,0 +1,101 @@ +google.devtools.cloudbuild.v2.FetchLinkableRepositoriesResponse + */ +class FetchLinkableRepositoriesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * repositories ready to be created. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.Repository repositories = 1; + */ + private $repositories; + /** + * A token identifying a page of results the server should return. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Build\V2\Repository>|\Google\Protobuf\Internal\RepeatedField $repositories + * repositories ready to be created. + * @type string $next_page_token + * A token identifying a page of results the server should return. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * repositories ready to be created. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.Repository repositories = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getRepositories() + { + return $this->repositories; + } + + /** + * repositories ready to be created. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.Repository repositories = 1; + * @param array<\Google\Cloud\Build\V2\Repository>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setRepositories($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Build\V2\Repository::class); + $this->repositories = $arr; + + return $this; + } + + /** + * A token identifying a page of results the server should return. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token identifying a page of results the server should return. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/FetchReadTokenRequest.php b/Build/src/V2/FetchReadTokenRequest.php new file mode 100644 index 00000000000..d5b9497a707 --- /dev/null +++ b/Build/src/V2/FetchReadTokenRequest.php @@ -0,0 +1,71 @@ +google.devtools.cloudbuild.v2.FetchReadTokenRequest + */ +class FetchReadTokenRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the repository in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string repository = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $repository = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $repository + * Required. The resource name of the repository in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the repository in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string repository = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getRepository() + { + return $this->repository; + } + + /** + * Required. The resource name of the repository in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string repository = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setRepository($var) + { + GPBUtil::checkString($var, True); + $this->repository = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/FetchReadTokenResponse.php b/Build/src/V2/FetchReadTokenResponse.php new file mode 100644 index 00000000000..fc8190cc7f3 --- /dev/null +++ b/Build/src/V2/FetchReadTokenResponse.php @@ -0,0 +1,111 @@ +google.devtools.cloudbuild.v2.FetchReadTokenResponse + */ +class FetchReadTokenResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The token content. + * + * Generated from protobuf field string token = 1; + */ + private $token = ''; + /** + * Expiration timestamp. Can be empty if unknown or non-expiring. + * + * Generated from protobuf field .google.protobuf.Timestamp expiration_time = 2; + */ + private $expiration_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $token + * The token content. + * @type \Google\Protobuf\Timestamp $expiration_time + * Expiration timestamp. Can be empty if unknown or non-expiring. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * The token content. + * + * Generated from protobuf field string token = 1; + * @return string + */ + public function getToken() + { + return $this->token; + } + + /** + * The token content. + * + * Generated from protobuf field string token = 1; + * @param string $var + * @return $this + */ + public function setToken($var) + { + GPBUtil::checkString($var, True); + $this->token = $var; + + return $this; + } + + /** + * Expiration timestamp. Can be empty if unknown or non-expiring. + * + * Generated from protobuf field .google.protobuf.Timestamp expiration_time = 2; + * @return \Google\Protobuf\Timestamp|null + */ + public function getExpirationTime() + { + return $this->expiration_time; + } + + public function hasExpirationTime() + { + return isset($this->expiration_time); + } + + public function clearExpirationTime() + { + unset($this->expiration_time); + } + + /** + * Expiration timestamp. Can be empty if unknown or non-expiring. + * + * Generated from protobuf field .google.protobuf.Timestamp expiration_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setExpirationTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->expiration_time = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/FetchReadWriteTokenRequest.php b/Build/src/V2/FetchReadWriteTokenRequest.php new file mode 100644 index 00000000000..42c2178d92f --- /dev/null +++ b/Build/src/V2/FetchReadWriteTokenRequest.php @@ -0,0 +1,71 @@ +google.devtools.cloudbuild.v2.FetchReadWriteTokenRequest + */ +class FetchReadWriteTokenRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the repository in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string repository = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $repository = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $repository + * Required. The resource name of the repository in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the repository in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string repository = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getRepository() + { + return $this->repository; + } + + /** + * Required. The resource name of the repository in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string repository = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setRepository($var) + { + GPBUtil::checkString($var, True); + $this->repository = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/FetchReadWriteTokenResponse.php b/Build/src/V2/FetchReadWriteTokenResponse.php new file mode 100644 index 00000000000..18a87ed5c44 --- /dev/null +++ b/Build/src/V2/FetchReadWriteTokenResponse.php @@ -0,0 +1,111 @@ +google.devtools.cloudbuild.v2.FetchReadWriteTokenResponse + */ +class FetchReadWriteTokenResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The token content. + * + * Generated from protobuf field string token = 1; + */ + private $token = ''; + /** + * Expiration timestamp. Can be empty if unknown or non-expiring. + * + * Generated from protobuf field .google.protobuf.Timestamp expiration_time = 2; + */ + private $expiration_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $token + * The token content. + * @type \Google\Protobuf\Timestamp $expiration_time + * Expiration timestamp. Can be empty if unknown or non-expiring. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * The token content. + * + * Generated from protobuf field string token = 1; + * @return string + */ + public function getToken() + { + return $this->token; + } + + /** + * The token content. + * + * Generated from protobuf field string token = 1; + * @param string $var + * @return $this + */ + public function setToken($var) + { + GPBUtil::checkString($var, True); + $this->token = $var; + + return $this; + } + + /** + * Expiration timestamp. Can be empty if unknown or non-expiring. + * + * Generated from protobuf field .google.protobuf.Timestamp expiration_time = 2; + * @return \Google\Protobuf\Timestamp|null + */ + public function getExpirationTime() + { + return $this->expiration_time; + } + + public function hasExpirationTime() + { + return isset($this->expiration_time); + } + + public function clearExpirationTime() + { + unset($this->expiration_time); + } + + /** + * Expiration timestamp. Can be empty if unknown or non-expiring. + * + * Generated from protobuf field .google.protobuf.Timestamp expiration_time = 2; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setExpirationTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->expiration_time = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/Gapic/RepositoryManagerGapicClient.php b/Build/src/V2/Gapic/RepositoryManagerGapicClient.php new file mode 100644 index 00000000000..342020766f1 --- /dev/null +++ b/Build/src/V2/Gapic/RepositoryManagerGapicClient.php @@ -0,0 +1,1392 @@ +connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + * $requests = []; + * $operationResponse = $repositoryManagerClient->batchCreateRepositories($formattedParent, $requests); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $repositoryManagerClient->batchCreateRepositories($formattedParent, $requests); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $repositoryManagerClient->resumeOperation($operationName, 'batchCreateRepositories'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * Many parameters require resource names to be formatted in a particular way. To + * assist with these names, this class includes a format method for each type of + * name, and additionally a parseName method to extract the individual identifiers + * contained within formatted names that are returned by the API. + */ +class RepositoryManagerGapicClient +{ + use GapicClientTrait; + + /** The name of the service. */ + const SERVICE_NAME = 'google.devtools.cloudbuild.v2.RepositoryManager'; + + /** The default address of the service. */ + const SERVICE_ADDRESS = 'cloudbuild.googleapis.com'; + + /** The default port of the service. */ + const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static $connectionNameTemplate; + + private static $locationNameTemplate; + + private static $repositoryNameTemplate; + + private static $pathTemplateMap; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/repository_manager_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/repository_manager_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/repository_manager_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/repository_manager_rest_client_config.php', + ], + ], + ]; + } + + private static function getConnectionNameTemplate() + { + if (self::$connectionNameTemplate == null) { + self::$connectionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/connections/{connection}'); + } + + return self::$connectionNameTemplate; + } + + private static function getLocationNameTemplate() + { + if (self::$locationNameTemplate == null) { + self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); + } + + return self::$locationNameTemplate; + } + + private static function getRepositoryNameTemplate() + { + if (self::$repositoryNameTemplate == null) { + self::$repositoryNameTemplate = new PathTemplate('projects/{project}/locations/{location}/connections/{connection}/repositories/{repository}'); + } + + return self::$repositoryNameTemplate; + } + + private static function getPathTemplateMap() + { + if (self::$pathTemplateMap == null) { + self::$pathTemplateMap = [ + 'connection' => self::getConnectionNameTemplate(), + 'location' => self::getLocationNameTemplate(), + 'repository' => self::getRepositoryNameTemplate(), + ]; + } + + return self::$pathTemplateMap; + } + + /** + * Formats a string containing the fully-qualified path to represent a connection + * resource. + * + * @param string $project + * @param string $location + * @param string $connection + * + * @return string The formatted connection resource. + */ + public static function connectionName($project, $location, $connection) + { + return self::getConnectionNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'connection' => $connection, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName($project, $location) + { + return self::getLocationNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a repository + * resource. + * + * @param string $project + * @param string $location + * @param string $connection + * @param string $repository + * + * @return string The formatted repository resource. + */ + public static function repositoryName($project, $location, $connection, $repository) + { + return self::getRepositoryNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'connection' => $connection, + 'repository' => $repository, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - connection: projects/{project}/locations/{location}/connections/{connection} + * - location: projects/{project}/locations/{location} + * - repository: projects/{project}/locations/{location}/connections/{connection}/repositories/{repository} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + */ + public static function parseName($formattedName, $template = null) + { + $templateMap = self::getPathTemplateMap(); + if ($template) { + if (!isset($templateMap[$template])) { + throw new ValidationException("Template name $template does not exist"); + } + + return $templateMap[$template]->match($formattedName); + } + + foreach ($templateMap as $templateName => $pathTemplate) { + try { + return $pathTemplate->match($formattedName); + } catch (ValidationException $ex) { + // Swallow the exception to continue trying other path templates + } + } + + throw new ValidationException("Input did not match any known format. Input: $formattedName"); + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'cloudbuild.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * } + * + * @throws ValidationException + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** + * Creates multiple repositories inside a connection. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $formattedParent = $repositoryManagerClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + * $requests = []; + * $operationResponse = $repositoryManagerClient->batchCreateRepositories($formattedParent, $requests); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $repositoryManagerClient->batchCreateRepositories($formattedParent, $requests); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $repositoryManagerClient->resumeOperation($operationName, 'batchCreateRepositories'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $parent Required. The connection to contain all the repositories being created. + * Format: projects/*/locations/*/connections/* + * The parent field in the CreateRepositoryRequest messages + * must either be empty or match this field. + * @param CreateRepositoryRequest[] $requests Required. The request messages specifying the repositories to create. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function batchCreateRepositories($parent, $requests, array $optionalArgs = []) + { + $request = new BatchCreateRepositoriesRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setRequests($requests); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('BatchCreateRepositories', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Creates a Connection. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $formattedParent = $repositoryManagerClient->locationName('[PROJECT]', '[LOCATION]'); + * $connection = new Connection(); + * $connectionId = 'connection_id'; + * $operationResponse = $repositoryManagerClient->createConnection($formattedParent, $connection, $connectionId); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $repositoryManagerClient->createConnection($formattedParent, $connection, $connectionId); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $repositoryManagerClient->resumeOperation($operationName, 'createConnection'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $parent Required. Project and location where the connection will be created. + * Format: `projects/*/locations/*`. + * @param Connection $connection Required. The Connection to create. + * @param string $connectionId Required. The ID to use for the Connection, which will become the final + * component of the Connection's resource name. Names must be unique + * per-project per-location. Allows alphanumeric characters and any of + * -._~%!$&'()*+,;=@. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function createConnection($parent, $connection, $connectionId, array $optionalArgs = []) + { + $request = new CreateConnectionRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setConnection($connection); + $request->setConnectionId($connectionId); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('CreateConnection', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Creates a Repository. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $formattedParent = $repositoryManagerClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + * $repository = new Repository(); + * $repositoryId = 'repository_id'; + * $operationResponse = $repositoryManagerClient->createRepository($formattedParent, $repository, $repositoryId); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $repositoryManagerClient->createRepository($formattedParent, $repository, $repositoryId); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $repositoryManagerClient->resumeOperation($operationName, 'createRepository'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $parent Required. The connection to contain the repository. If the request is part + * of a BatchCreateRepositoriesRequest, this field should be empty or match + * the parent specified there. + * @param Repository $repository Required. The repository to create. + * @param string $repositoryId Required. The ID to use for the repository, which will become the final + * component of the repository's resource name. This ID should be unique in + * the connection. Allows alphanumeric characters and any of + * -._~%!$&'()*+,;=@. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function createRepository($parent, $repository, $repositoryId, array $optionalArgs = []) + { + $request = new CreateRepositoryRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setRepository($repository); + $request->setRepositoryId($repositoryId); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('CreateRepository', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Deletes a single connection. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $formattedName = $repositoryManagerClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + * $operationResponse = $repositoryManagerClient->deleteConnection($formattedName); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $repositoryManagerClient->deleteConnection($formattedName); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $repositoryManagerClient->resumeOperation($operationName, 'deleteConnection'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the Connection to delete. + * Format: `projects/*/locations/*/connections/*`. + * @param array $optionalArgs { + * Optional. + * + * @type string $etag + * The current etag of the connection. + * If an etag is provided and does not match the current etag of the + * connection, deletion will be blocked and an ABORTED error will be returned. + * @type bool $validateOnly + * If set, validate the request, but do not actually post it. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function deleteConnection($name, array $optionalArgs = []) + { + $request = new DeleteConnectionRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['etag'])) { + $request->setEtag($optionalArgs['etag']); + } + + if (isset($optionalArgs['validateOnly'])) { + $request->setValidateOnly($optionalArgs['validateOnly']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('DeleteConnection', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Deletes a single repository. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $formattedName = $repositoryManagerClient->repositoryName('[PROJECT]', '[LOCATION]', '[CONNECTION]', '[REPOSITORY]'); + * $operationResponse = $repositoryManagerClient->deleteRepository($formattedName); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $repositoryManagerClient->deleteRepository($formattedName); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $repositoryManagerClient->resumeOperation($operationName, 'deleteRepository'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the Repository to delete. + * Format: `projects/*/locations/*/connections/*/repositories/*`. + * @param array $optionalArgs { + * Optional. + * + * @type string $etag + * The current etag of the repository. + * If an etag is provided and does not match the current etag of the + * repository, deletion will be blocked and an ABORTED error will be returned. + * @type bool $validateOnly + * If set, validate the request, but do not actually post it. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function deleteRepository($name, array $optionalArgs = []) + { + $request = new DeleteRepositoryRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['etag'])) { + $request->setEtag($optionalArgs['etag']); + } + + if (isset($optionalArgs['validateOnly'])) { + $request->setValidateOnly($optionalArgs['validateOnly']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('DeleteRepository', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * FetchLinkableRepositories get repositories from SCM that are + * accessible and could be added to the connection. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $formattedConnection = $repositoryManagerClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + * // Iterate over pages of elements + * $pagedResponse = $repositoryManagerClient->fetchLinkableRepositories($formattedConnection); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $repositoryManagerClient->fetchLinkableRepositories($formattedConnection); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $connection Required. The name of the Connection. + * Format: `projects/*/locations/*/connections/*`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function fetchLinkableRepositories($connection, array $optionalArgs = []) + { + $request = new FetchLinkableRepositoriesRequest(); + $requestParamHeaders = []; + $request->setConnection($connection); + $requestParamHeaders['connection'] = $connection; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('FetchLinkableRepositories', $optionalArgs, FetchLinkableRepositoriesResponse::class, $request); + } + + /** + * Fetches read token of a given repository. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $formattedRepository = $repositoryManagerClient->repositoryName('[PROJECT]', '[LOCATION]', '[CONNECTION]', '[REPOSITORY]'); + * $response = $repositoryManagerClient->fetchReadToken($formattedRepository); + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $repository Required. The resource name of the repository in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Build\V2\FetchReadTokenResponse + * + * @throws ApiException if the remote call fails + */ + public function fetchReadToken($repository, array $optionalArgs = []) + { + $request = new FetchReadTokenRequest(); + $requestParamHeaders = []; + $request->setRepository($repository); + $requestParamHeaders['repository'] = $repository; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('FetchReadToken', FetchReadTokenResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Fetches read/write token of a given repository. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $formattedRepository = $repositoryManagerClient->repositoryName('[PROJECT]', '[LOCATION]', '[CONNECTION]', '[REPOSITORY]'); + * $response = $repositoryManagerClient->fetchReadWriteToken($formattedRepository); + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $repository Required. The resource name of the repository in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Build\V2\FetchReadWriteTokenResponse + * + * @throws ApiException if the remote call fails + */ + public function fetchReadWriteToken($repository, array $optionalArgs = []) + { + $request = new FetchReadWriteTokenRequest(); + $requestParamHeaders = []; + $request->setRepository($repository); + $requestParamHeaders['repository'] = $repository; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('FetchReadWriteToken', FetchReadWriteTokenResponse::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets details of a single connection. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $formattedName = $repositoryManagerClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + * $response = $repositoryManagerClient->getConnection($formattedName); + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the Connection to retrieve. + * Format: `projects/*/locations/*/connections/*`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Build\V2\Connection + * + * @throws ApiException if the remote call fails + */ + public function getConnection($name, array $optionalArgs = []) + { + $request = new GetConnectionRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetConnection', Connection::class, $optionalArgs, $request)->wait(); + } + + /** + * Gets details of a single repository. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $formattedName = $repositoryManagerClient->repositoryName('[PROJECT]', '[LOCATION]', '[CONNECTION]', '[REPOSITORY]'); + * $response = $repositoryManagerClient->getRepository($formattedName); + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the Repository to retrieve. + * Format: `projects/*/locations/*/connections/*/repositories/*`. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Build\V2\Repository + * + * @throws ApiException if the remote call fails + */ + public function getRepository($name, array $optionalArgs = []) + { + $request = new GetRepositoryRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetRepository', Repository::class, $optionalArgs, $request)->wait(); + } + + /** + * Lists Connections in a given project and location. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $formattedParent = $repositoryManagerClient->locationName('[PROJECT]', '[LOCATION]'); + * // Iterate over pages of elements + * $pagedResponse = $repositoryManagerClient->listConnections($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $repositoryManagerClient->listConnections($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $parent Required. The parent, which owns this collection of Connections. + * Format: `projects/*/locations/*`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listConnections($parent, array $optionalArgs = []) + { + $request = new ListConnectionsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListConnections', $optionalArgs, ListConnectionsResponse::class, $request); + } + + /** + * Lists Repositories in a given connection. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $formattedParent = $repositoryManagerClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + * // Iterate over pages of elements + * $pagedResponse = $repositoryManagerClient->listRepositories($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $repositoryManagerClient->listRepositories($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $parent Required. The parent, which owns this collection of Repositories. + * Format: `projects/*/locations/*/connections/*`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type string $filter + * A filter expression that filters resources listed in the response. + * Expressions must follow API improvement proposal + * [AIP-160](https://google.aip.dev/160). e.g. + * `remote_uri:"https://github.com*"`. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listRepositories($parent, array $optionalArgs = []) + { + $request = new ListRepositoriesRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListRepositories', $optionalArgs, ListRepositoriesResponse::class, $request); + } + + /** + * Updates a single connection. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $connection = new Connection(); + * $operationResponse = $repositoryManagerClient->updateConnection($connection); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $repositoryManagerClient->updateConnection($connection); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $repositoryManagerClient->resumeOperation($operationName, 'updateConnection'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param Connection $connection Required. The Connection to update. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $updateMask + * The list of fields to be updated. + * @type bool $allowMissing + * If set to true, and the connection is not found a new connection + * will be created. In this situation `update_mask` is ignored. + * The creation will succeed only if the input connection has all the + * necessary information (e.g a github_config with both user_oauth_token and + * installation_id properties). + * @type string $etag + * The current etag of the connection. + * If an etag is provided and does not match the current etag of the + * connection, update will be blocked and an ABORTED error will be returned. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function updateConnection($connection, array $optionalArgs = []) + { + $request = new UpdateConnectionRequest(); + $requestParamHeaders = []; + $request->setConnection($connection); + $requestParamHeaders['connection.name'] = $connection->getName(); + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } + + if (isset($optionalArgs['allowMissing'])) { + $request->setAllowMissing($optionalArgs['allowMissing']); + } + + if (isset($optionalArgs['etag'])) { + $request->setEtag($optionalArgs['etag']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startOperationsCall('UpdateConnection', $optionalArgs, $request, $this->getOperationsClient())->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $resource = 'resource'; + * $response = $repositoryManagerClient->getIamPolicy($resource); + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param array $optionalArgs { + * Optional. + * + * @type GetPolicyOptions $options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Iam\V1\Policy + * + * @throws ApiException if the remote call fails + */ + public function getIamPolicy($resource, array $optionalArgs = []) + { + $request = new GetIamPolicyRequest(); + $requestParamHeaders = []; + $request->setResource($resource); + $requestParamHeaders['resource'] = $resource; + if (isset($optionalArgs['options'])) { + $request->setOptions($optionalArgs['options']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetIamPolicy', Policy::class, $optionalArgs, $request, Call::UNARY_CALL, 'google.iam.v1.IAMPolicy')->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $resource = 'resource'; + * $policy = new Policy(); + * $response = $repositoryManagerClient->setIamPolicy($resource, $policy); + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Iam\V1\Policy + * + * @throws ApiException if the remote call fails + */ + public function setIamPolicy($resource, $policy, array $optionalArgs = []) + { + $request = new SetIamPolicyRequest(); + $requestParamHeaders = []; + $request->setResource($resource); + $request->setPolicy($policy); + $requestParamHeaders['resource'] = $resource; + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('SetIamPolicy', Policy::class, $optionalArgs, $request, Call::UNARY_CALL, 'google.iam.v1.IAMPolicy')->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * Sample code: + * ``` + * $repositoryManagerClient = new RepositoryManagerClient(); + * try { + * $resource = 'resource'; + * $permissions = []; + * $response = $repositoryManagerClient->testIamPermissions($resource, $permissions); + * } finally { + * $repositoryManagerClient->close(); + * } + * ``` + * + * @param string $resource REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Iam\V1\TestIamPermissionsResponse + * + * @throws ApiException if the remote call fails + */ + public function testIamPermissions($resource, $permissions, array $optionalArgs = []) + { + $request = new TestIamPermissionsRequest(); + $requestParamHeaders = []; + $request->setResource($resource); + $request->setPermissions($permissions); + $requestParamHeaders['resource'] = $resource; + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('TestIamPermissions', TestIamPermissionsResponse::class, $optionalArgs, $request, Call::UNARY_CALL, 'google.iam.v1.IAMPolicy')->wait(); + } +} diff --git a/Build/src/V2/GetConnectionRequest.php b/Build/src/V2/GetConnectionRequest.php new file mode 100644 index 00000000000..6b373555e5c --- /dev/null +++ b/Build/src/V2/GetConnectionRequest.php @@ -0,0 +1,71 @@ +google.devtools.cloudbuild.v2.GetConnectionRequest + */ +class GetConnectionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the Connection to retrieve. + * Format: `projects/*/locations/*/connections/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the Connection to retrieve. + * Format: `projects/*/locations/*/connections/*`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the Connection to retrieve. + * Format: `projects/*/locations/*/connections/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The name of the Connection to retrieve. + * Format: `projects/*/locations/*/connections/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/GetRepositoryRequest.php b/Build/src/V2/GetRepositoryRequest.php new file mode 100644 index 00000000000..2423d6742aa --- /dev/null +++ b/Build/src/V2/GetRepositoryRequest.php @@ -0,0 +1,71 @@ +google.devtools.cloudbuild.v2.GetRepositoryRequest + */ +class GetRepositoryRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the Repository to retrieve. + * Format: `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the Repository to retrieve. + * Format: `projects/*/locations/*/connections/*/repositories/*`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the Repository to retrieve. + * Format: `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The name of the Repository to retrieve. + * Format: `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/GitHubConfig.php b/Build/src/V2/GitHubConfig.php new file mode 100644 index 00000000000..ceaf4c2599b --- /dev/null +++ b/Build/src/V2/GitHubConfig.php @@ -0,0 +1,119 @@ +google.devtools.cloudbuild.v2.GitHubConfig + */ +class GitHubConfig extends \Google\Protobuf\Internal\Message +{ + /** + * OAuth credential of the account that authorized the Cloud Build GitHub App. + * It is recommended to use a robot account instead of a human user account. + * The OAuth token must be tied to the Cloud Build GitHub App. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.OAuthCredential authorizer_credential = 1; + */ + private $authorizer_credential = null; + /** + * GitHub App installation id. + * + * Generated from protobuf field int64 app_installation_id = 2; + */ + private $app_installation_id = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Build\V2\OAuthCredential $authorizer_credential + * OAuth credential of the account that authorized the Cloud Build GitHub App. + * It is recommended to use a robot account instead of a human user account. + * The OAuth token must be tied to the Cloud Build GitHub App. + * @type int|string $app_installation_id + * GitHub App installation id. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * OAuth credential of the account that authorized the Cloud Build GitHub App. + * It is recommended to use a robot account instead of a human user account. + * The OAuth token must be tied to the Cloud Build GitHub App. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.OAuthCredential authorizer_credential = 1; + * @return \Google\Cloud\Build\V2\OAuthCredential|null + */ + public function getAuthorizerCredential() + { + return $this->authorizer_credential; + } + + public function hasAuthorizerCredential() + { + return isset($this->authorizer_credential); + } + + public function clearAuthorizerCredential() + { + unset($this->authorizer_credential); + } + + /** + * OAuth credential of the account that authorized the Cloud Build GitHub App. + * It is recommended to use a robot account instead of a human user account. + * The OAuth token must be tied to the Cloud Build GitHub App. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.OAuthCredential authorizer_credential = 1; + * @param \Google\Cloud\Build\V2\OAuthCredential $var + * @return $this + */ + public function setAuthorizerCredential($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Build\V2\OAuthCredential::class); + $this->authorizer_credential = $var; + + return $this; + } + + /** + * GitHub App installation id. + * + * Generated from protobuf field int64 app_installation_id = 2; + * @return int|string + */ + public function getAppInstallationId() + { + return $this->app_installation_id; + } + + /** + * GitHub App installation id. + * + * Generated from protobuf field int64 app_installation_id = 2; + * @param int|string $var + * @return $this + */ + public function setAppInstallationId($var) + { + GPBUtil::checkInt64($var); + $this->app_installation_id = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/GitHubEnterpriseConfig.php b/Build/src/V2/GitHubEnterpriseConfig.php new file mode 100644 index 00000000000..27124ed5cc1 --- /dev/null +++ b/Build/src/V2/GitHubEnterpriseConfig.php @@ -0,0 +1,407 @@ +google.devtools.cloudbuild.v2.GitHubEnterpriseConfig + */ +class GitHubEnterpriseConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The URI of the GitHub Enterprise host this connection is for. + * + * Generated from protobuf field string host_uri = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $host_uri = ''; + /** + * Required. API Key used for authentication of webhook events. + * + * Generated from protobuf field string api_key = 12 [(.google.api.field_behavior) = REQUIRED]; + */ + private $api_key = ''; + /** + * Id of the GitHub App created from the manifest. + * + * Generated from protobuf field int64 app_id = 2; + */ + private $app_id = 0; + /** + * The URL-friendly name of the GitHub App. + * + * Generated from protobuf field string app_slug = 13; + */ + private $app_slug = ''; + /** + * SecretManager resource containing the private key of the GitHub App, + * formatted as `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string private_key_secret_version = 4 [(.google.api.resource_reference) = { + */ + private $private_key_secret_version = ''; + /** + * SecretManager resource containing the webhook secret of the GitHub App, + * formatted as `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string webhook_secret_secret_version = 5 [(.google.api.resource_reference) = { + */ + private $webhook_secret_secret_version = ''; + /** + * ID of the installation of the GitHub App. + * + * Generated from protobuf field int64 app_installation_id = 9; + */ + private $app_installation_id = 0; + /** + * Configuration for using Service Directory to privately connect to a GitHub + * Enterprise server. This should only be set if the GitHub Enterprise server + * is hosted on-premises and not reachable by public internet. If this field + * is left empty, calls to the GitHub Enterprise server will be made over the + * public internet. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.ServiceDirectoryConfig service_directory_config = 10; + */ + private $service_directory_config = null; + /** + * SSL certificate to use for requests to GitHub Enterprise. + * + * Generated from protobuf field string ssl_ca = 11; + */ + private $ssl_ca = ''; + /** + * Output only. GitHub Enterprise version installed at the host_uri. + * + * Generated from protobuf field string server_version = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $server_version = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $host_uri + * Required. The URI of the GitHub Enterprise host this connection is for. + * @type string $api_key + * Required. API Key used for authentication of webhook events. + * @type int|string $app_id + * Id of the GitHub App created from the manifest. + * @type string $app_slug + * The URL-friendly name of the GitHub App. + * @type string $private_key_secret_version + * SecretManager resource containing the private key of the GitHub App, + * formatted as `projects/*/secrets/*/versions/*`. + * @type string $webhook_secret_secret_version + * SecretManager resource containing the webhook secret of the GitHub App, + * formatted as `projects/*/secrets/*/versions/*`. + * @type int|string $app_installation_id + * ID of the installation of the GitHub App. + * @type \Google\Cloud\Build\V2\ServiceDirectoryConfig $service_directory_config + * Configuration for using Service Directory to privately connect to a GitHub + * Enterprise server. This should only be set if the GitHub Enterprise server + * is hosted on-premises and not reachable by public internet. If this field + * is left empty, calls to the GitHub Enterprise server will be made over the + * public internet. + * @type string $ssl_ca + * SSL certificate to use for requests to GitHub Enterprise. + * @type string $server_version + * Output only. GitHub Enterprise version installed at the host_uri. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The URI of the GitHub Enterprise host this connection is for. + * + * Generated from protobuf field string host_uri = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getHostUri() + { + return $this->host_uri; + } + + /** + * Required. The URI of the GitHub Enterprise host this connection is for. + * + * Generated from protobuf field string host_uri = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setHostUri($var) + { + GPBUtil::checkString($var, True); + $this->host_uri = $var; + + return $this; + } + + /** + * Required. API Key used for authentication of webhook events. + * + * Generated from protobuf field string api_key = 12 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getApiKey() + { + return $this->api_key; + } + + /** + * Required. API Key used for authentication of webhook events. + * + * Generated from protobuf field string api_key = 12 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setApiKey($var) + { + GPBUtil::checkString($var, True); + $this->api_key = $var; + + return $this; + } + + /** + * Id of the GitHub App created from the manifest. + * + * Generated from protobuf field int64 app_id = 2; + * @return int|string + */ + public function getAppId() + { + return $this->app_id; + } + + /** + * Id of the GitHub App created from the manifest. + * + * Generated from protobuf field int64 app_id = 2; + * @param int|string $var + * @return $this + */ + public function setAppId($var) + { + GPBUtil::checkInt64($var); + $this->app_id = $var; + + return $this; + } + + /** + * The URL-friendly name of the GitHub App. + * + * Generated from protobuf field string app_slug = 13; + * @return string + */ + public function getAppSlug() + { + return $this->app_slug; + } + + /** + * The URL-friendly name of the GitHub App. + * + * Generated from protobuf field string app_slug = 13; + * @param string $var + * @return $this + */ + public function setAppSlug($var) + { + GPBUtil::checkString($var, True); + $this->app_slug = $var; + + return $this; + } + + /** + * SecretManager resource containing the private key of the GitHub App, + * formatted as `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string private_key_secret_version = 4 [(.google.api.resource_reference) = { + * @return string + */ + public function getPrivateKeySecretVersion() + { + return $this->private_key_secret_version; + } + + /** + * SecretManager resource containing the private key of the GitHub App, + * formatted as `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string private_key_secret_version = 4 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setPrivateKeySecretVersion($var) + { + GPBUtil::checkString($var, True); + $this->private_key_secret_version = $var; + + return $this; + } + + /** + * SecretManager resource containing the webhook secret of the GitHub App, + * formatted as `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string webhook_secret_secret_version = 5 [(.google.api.resource_reference) = { + * @return string + */ + public function getWebhookSecretSecretVersion() + { + return $this->webhook_secret_secret_version; + } + + /** + * SecretManager resource containing the webhook secret of the GitHub App, + * formatted as `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string webhook_secret_secret_version = 5 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setWebhookSecretSecretVersion($var) + { + GPBUtil::checkString($var, True); + $this->webhook_secret_secret_version = $var; + + return $this; + } + + /** + * ID of the installation of the GitHub App. + * + * Generated from protobuf field int64 app_installation_id = 9; + * @return int|string + */ + public function getAppInstallationId() + { + return $this->app_installation_id; + } + + /** + * ID of the installation of the GitHub App. + * + * Generated from protobuf field int64 app_installation_id = 9; + * @param int|string $var + * @return $this + */ + public function setAppInstallationId($var) + { + GPBUtil::checkInt64($var); + $this->app_installation_id = $var; + + return $this; + } + + /** + * Configuration for using Service Directory to privately connect to a GitHub + * Enterprise server. This should only be set if the GitHub Enterprise server + * is hosted on-premises and not reachable by public internet. If this field + * is left empty, calls to the GitHub Enterprise server will be made over the + * public internet. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.ServiceDirectoryConfig service_directory_config = 10; + * @return \Google\Cloud\Build\V2\ServiceDirectoryConfig|null + */ + public function getServiceDirectoryConfig() + { + return $this->service_directory_config; + } + + public function hasServiceDirectoryConfig() + { + return isset($this->service_directory_config); + } + + public function clearServiceDirectoryConfig() + { + unset($this->service_directory_config); + } + + /** + * Configuration for using Service Directory to privately connect to a GitHub + * Enterprise server. This should only be set if the GitHub Enterprise server + * is hosted on-premises and not reachable by public internet. If this field + * is left empty, calls to the GitHub Enterprise server will be made over the + * public internet. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.ServiceDirectoryConfig service_directory_config = 10; + * @param \Google\Cloud\Build\V2\ServiceDirectoryConfig $var + * @return $this + */ + public function setServiceDirectoryConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Build\V2\ServiceDirectoryConfig::class); + $this->service_directory_config = $var; + + return $this; + } + + /** + * SSL certificate to use for requests to GitHub Enterprise. + * + * Generated from protobuf field string ssl_ca = 11; + * @return string + */ + public function getSslCa() + { + return $this->ssl_ca; + } + + /** + * SSL certificate to use for requests to GitHub Enterprise. + * + * Generated from protobuf field string ssl_ca = 11; + * @param string $var + * @return $this + */ + public function setSslCa($var) + { + GPBUtil::checkString($var, True); + $this->ssl_ca = $var; + + return $this; + } + + /** + * Output only. GitHub Enterprise version installed at the host_uri. + * + * Generated from protobuf field string server_version = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getServerVersion() + { + return $this->server_version; + } + + /** + * Output only. GitHub Enterprise version installed at the host_uri. + * + * Generated from protobuf field string server_version = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setServerVersion($var) + { + GPBUtil::checkString($var, True); + $this->server_version = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/InstallationState.php b/Build/src/V2/InstallationState.php new file mode 100644 index 00000000000..d0754dabd95 --- /dev/null +++ b/Build/src/V2/InstallationState.php @@ -0,0 +1,145 @@ +google.devtools.cloudbuild.v2.InstallationState + */ +class InstallationState extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. Current step of the installation process. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.InstallationState.Stage stage = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $stage = 0; + /** + * Output only. Message of what the user should do next to continue the + * installation. Empty string if the installation is already complete. + * + * Generated from protobuf field string message = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $message = ''; + /** + * Output only. Link to follow for next action. Empty string if the + * installation is already complete. + * + * Generated from protobuf field string action_uri = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $action_uri = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $stage + * Output only. Current step of the installation process. + * @type string $message + * Output only. Message of what the user should do next to continue the + * installation. Empty string if the installation is already complete. + * @type string $action_uri + * Output only. Link to follow for next action. Empty string if the + * installation is already complete. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Output only. Current step of the installation process. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.InstallationState.Stage stage = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getStage() + { + return $this->stage; + } + + /** + * Output only. Current step of the installation process. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.InstallationState.Stage stage = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setStage($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Build\V2\InstallationState\Stage::class); + $this->stage = $var; + + return $this; + } + + /** + * Output only. Message of what the user should do next to continue the + * installation. Empty string if the installation is already complete. + * + * Generated from protobuf field string message = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * Output only. Message of what the user should do next to continue the + * installation. Empty string if the installation is already complete. + * + * Generated from protobuf field string message = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setMessage($var) + { + GPBUtil::checkString($var, True); + $this->message = $var; + + return $this; + } + + /** + * Output only. Link to follow for next action. Empty string if the + * installation is already complete. + * + * Generated from protobuf field string action_uri = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getActionUri() + { + return $this->action_uri; + } + + /** + * Output only. Link to follow for next action. Empty string if the + * installation is already complete. + * + * Generated from protobuf field string action_uri = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setActionUri($var) + { + GPBUtil::checkString($var, True); + $this->action_uri = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/InstallationState/Stage.php b/Build/src/V2/InstallationState/Stage.php new file mode 100644 index 00000000000..bcaf482a392 --- /dev/null +++ b/Build/src/V2/InstallationState/Stage.php @@ -0,0 +1,77 @@ +google.devtools.cloudbuild.v2.InstallationState.Stage + */ +class Stage +{ + /** + * No stage specified. + * + * Generated from protobuf enum STAGE_UNSPECIFIED = 0; + */ + const STAGE_UNSPECIFIED = 0; + /** + * Only for GitHub Enterprise. An App creation has been requested. + * The user needs to confirm the creation in their GitHub enterprise host. + * + * Generated from protobuf enum PENDING_CREATE_APP = 1; + */ + const PENDING_CREATE_APP = 1; + /** + * User needs to authorize the GitHub (or Enterprise) App via OAuth. + * + * Generated from protobuf enum PENDING_USER_OAUTH = 2; + */ + const PENDING_USER_OAUTH = 2; + /** + * User needs to follow the link to install the GitHub (or Enterprise) App. + * + * Generated from protobuf enum PENDING_INSTALL_APP = 3; + */ + const PENDING_INSTALL_APP = 3; + /** + * Installation process has been completed. + * + * Generated from protobuf enum COMPLETE = 10; + */ + const COMPLETE = 10; + + private static $valueToName = [ + self::STAGE_UNSPECIFIED => 'STAGE_UNSPECIFIED', + self::PENDING_CREATE_APP => 'PENDING_CREATE_APP', + self::PENDING_USER_OAUTH => 'PENDING_USER_OAUTH', + self::PENDING_INSTALL_APP => 'PENDING_INSTALL_APP', + self::COMPLETE => 'COMPLETE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/Build/src/V2/ListConnectionsRequest.php b/Build/src/V2/ListConnectionsRequest.php new file mode 100644 index 00000000000..b1cc2c4cea3 --- /dev/null +++ b/Build/src/V2/ListConnectionsRequest.php @@ -0,0 +1,139 @@ +google.devtools.cloudbuild.v2.ListConnectionsRequest + */ +class ListConnectionsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent, which owns this collection of Connections. + * Format: `projects/*/locations/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Number of results to return in the list. + * + * Generated from protobuf field int32 page_size = 2; + */ + private $page_size = 0; + /** + * Page start. + * + * Generated from protobuf field string page_token = 3; + */ + private $page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent, which owns this collection of Connections. + * Format: `projects/*/locations/*`. + * @type int $page_size + * Number of results to return in the list. + * @type string $page_token + * Page start. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent, which owns this collection of Connections. + * Format: `projects/*/locations/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The parent, which owns this collection of Connections. + * Format: `projects/*/locations/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Number of results to return in the list. + * + * Generated from protobuf field int32 page_size = 2; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of results to return in the list. + * + * Generated from protobuf field int32 page_size = 2; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Page start. + * + * Generated from protobuf field string page_token = 3; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Page start. + * + * Generated from protobuf field string page_token = 3; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/ListConnectionsResponse.php b/Build/src/V2/ListConnectionsResponse.php new file mode 100644 index 00000000000..dbcd4275d0b --- /dev/null +++ b/Build/src/V2/ListConnectionsResponse.php @@ -0,0 +1,101 @@ +google.devtools.cloudbuild.v2.ListConnectionsResponse + */ +class ListConnectionsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of Connections. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.Connection connections = 1; + */ + private $connections; + /** + * A token identifying a page of results the server should return. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Build\V2\Connection>|\Google\Protobuf\Internal\RepeatedField $connections + * The list of Connections. + * @type string $next_page_token + * A token identifying a page of results the server should return. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * The list of Connections. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.Connection connections = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getConnections() + { + return $this->connections; + } + + /** + * The list of Connections. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.Connection connections = 1; + * @param array<\Google\Cloud\Build\V2\Connection>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setConnections($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Build\V2\Connection::class); + $this->connections = $arr; + + return $this; + } + + /** + * A token identifying a page of results the server should return. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token identifying a page of results the server should return. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/ListRepositoriesRequest.php b/Build/src/V2/ListRepositoriesRequest.php new file mode 100644 index 00000000000..269edf1d5e5 --- /dev/null +++ b/Build/src/V2/ListRepositoriesRequest.php @@ -0,0 +1,185 @@ +google.devtools.cloudbuild.v2.ListRepositoriesRequest + */ +class ListRepositoriesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent, which owns this collection of Repositories. + * Format: `projects/*/locations/*/connections/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Number of results to return in the list. + * + * Generated from protobuf field int32 page_size = 2; + */ + private $page_size = 0; + /** + * Page start. + * + * Generated from protobuf field string page_token = 3; + */ + private $page_token = ''; + /** + * A filter expression that filters resources listed in the response. + * Expressions must follow API improvement proposal + * [AIP-160](https://google.aip.dev/160). e.g. + * `remote_uri:"https://github.com*"`. + * + * Generated from protobuf field string filter = 4; + */ + private $filter = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent, which owns this collection of Repositories. + * Format: `projects/*/locations/*/connections/*`. + * @type int $page_size + * Number of results to return in the list. + * @type string $page_token + * Page start. + * @type string $filter + * A filter expression that filters resources listed in the response. + * Expressions must follow API improvement proposal + * [AIP-160](https://google.aip.dev/160). e.g. + * `remote_uri:"https://github.com*"`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent, which owns this collection of Repositories. + * Format: `projects/*/locations/*/connections/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The parent, which owns this collection of Repositories. + * Format: `projects/*/locations/*/connections/*`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Number of results to return in the list. + * + * Generated from protobuf field int32 page_size = 2; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Number of results to return in the list. + * + * Generated from protobuf field int32 page_size = 2; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Page start. + * + * Generated from protobuf field string page_token = 3; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Page start. + * + * Generated from protobuf field string page_token = 3; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * A filter expression that filters resources listed in the response. + * Expressions must follow API improvement proposal + * [AIP-160](https://google.aip.dev/160). e.g. + * `remote_uri:"https://github.com*"`. + * + * Generated from protobuf field string filter = 4; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * A filter expression that filters resources listed in the response. + * Expressions must follow API improvement proposal + * [AIP-160](https://google.aip.dev/160). e.g. + * `remote_uri:"https://github.com*"`. + * + * Generated from protobuf field string filter = 4; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/ListRepositoriesResponse.php b/Build/src/V2/ListRepositoriesResponse.php new file mode 100644 index 00000000000..069a03c900e --- /dev/null +++ b/Build/src/V2/ListRepositoriesResponse.php @@ -0,0 +1,101 @@ +google.devtools.cloudbuild.v2.ListRepositoriesResponse + */ +class ListRepositoriesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of Repositories. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.Repository repositories = 1; + */ + private $repositories; + /** + * A token identifying a page of results the server should return. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\Build\V2\Repository>|\Google\Protobuf\Internal\RepeatedField $repositories + * The list of Repositories. + * @type string $next_page_token + * A token identifying a page of results the server should return. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * The list of Repositories. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.Repository repositories = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getRepositories() + { + return $this->repositories; + } + + /** + * The list of Repositories. + * + * Generated from protobuf field repeated .google.devtools.cloudbuild.v2.Repository repositories = 1; + * @param array<\Google\Cloud\Build\V2\Repository>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setRepositories($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Build\V2\Repository::class); + $this->repositories = $arr; + + return $this; + } + + /** + * A token identifying a page of results the server should return. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token identifying a page of results the server should return. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/OAuthCredential.php b/Build/src/V2/OAuthCredential.php new file mode 100644 index 00000000000..aebdcc892fa --- /dev/null +++ b/Build/src/V2/OAuthCredential.php @@ -0,0 +1,106 @@ +google.devtools.cloudbuild.v2.OAuthCredential + */ +class OAuthCredential extends \Google\Protobuf\Internal\Message +{ + /** + * A SecretManager resource containing the OAuth token that authorizes + * the Cloud Build connection. Format: `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string oauth_token_secret_version = 1 [(.google.api.resource_reference) = { + */ + private $oauth_token_secret_version = ''; + /** + * Output only. The username associated to this token. + * + * Generated from protobuf field string username = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $username = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $oauth_token_secret_version + * A SecretManager resource containing the OAuth token that authorizes + * the Cloud Build connection. Format: `projects/*/secrets/*/versions/*`. + * @type string $username + * Output only. The username associated to this token. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * A SecretManager resource containing the OAuth token that authorizes + * the Cloud Build connection. Format: `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string oauth_token_secret_version = 1 [(.google.api.resource_reference) = { + * @return string + */ + public function getOauthTokenSecretVersion() + { + return $this->oauth_token_secret_version; + } + + /** + * A SecretManager resource containing the OAuth token that authorizes + * the Cloud Build connection. Format: `projects/*/secrets/*/versions/*`. + * + * Generated from protobuf field string oauth_token_secret_version = 1 [(.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setOauthTokenSecretVersion($var) + { + GPBUtil::checkString($var, True); + $this->oauth_token_secret_version = $var; + + return $this; + } + + /** + * Output only. The username associated to this token. + * + * Generated from protobuf field string username = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getUsername() + { + return $this->username; + } + + /** + * Output only. The username associated to this token. + * + * Generated from protobuf field string username = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setUsername($var) + { + GPBUtil::checkString($var, True); + $this->username = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/OperationMetadata.php b/Build/src/V2/OperationMetadata.php new file mode 100644 index 00000000000..7e57729c84e --- /dev/null +++ b/Build/src/V2/OperationMetadata.php @@ -0,0 +1,307 @@ +google.devtools.cloudbuild.v2.OperationMetadata + */ +class OperationMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The time the operation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $create_time = null; + /** + * Output only. The time the operation finished running. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $end_time = null; + /** + * Output only. Server-defined resource path for the target of the operation. + * + * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $target = ''; + /** + * Output only. Name of the verb executed by the operation. + * + * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $verb = ''; + /** + * Output only. Human-readable status of the operation, if any. + * + * Generated from protobuf field string status_message = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $status_message = ''; + /** + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have successfully been cancelled + * have [Operation.error][] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * + * Generated from protobuf field bool requested_cancellation = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $requested_cancellation = false; + /** + * Output only. API version used to start the operation. + * + * Generated from protobuf field string api_version = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $api_version = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Timestamp $create_time + * Output only. The time the operation was created. + * @type \Google\Protobuf\Timestamp $end_time + * Output only. The time the operation finished running. + * @type string $target + * Output only. Server-defined resource path for the target of the operation. + * @type string $verb + * Output only. Name of the verb executed by the operation. + * @type string $status_message + * Output only. Human-readable status of the operation, if any. + * @type bool $requested_cancellation + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have successfully been cancelled + * have [Operation.error][] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * @type string $api_version + * Output only. API version used to start the operation. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Cloudbuild::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The time the operation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. The time the operation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. The time the operation finished running. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getEndTime() + { + return $this->end_time; + } + + public function hasEndTime() + { + return isset($this->end_time); + } + + public function clearEndTime() + { + unset($this->end_time); + } + + /** + * Output only. The time the operation finished running. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setEndTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->end_time = $var; + + return $this; + } + + /** + * Output only. Server-defined resource path for the target of the operation. + * + * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getTarget() + { + return $this->target; + } + + /** + * Output only. Server-defined resource path for the target of the operation. + * + * Generated from protobuf field string target = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setTarget($var) + { + GPBUtil::checkString($var, True); + $this->target = $var; + + return $this; + } + + /** + * Output only. Name of the verb executed by the operation. + * + * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getVerb() + { + return $this->verb; + } + + /** + * Output only. Name of the verb executed by the operation. + * + * Generated from protobuf field string verb = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setVerb($var) + { + GPBUtil::checkString($var, True); + $this->verb = $var; + + return $this; + } + + /** + * Output only. Human-readable status of the operation, if any. + * + * Generated from protobuf field string status_message = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getStatusMessage() + { + return $this->status_message; + } + + /** + * Output only. Human-readable status of the operation, if any. + * + * Generated from protobuf field string status_message = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setStatusMessage($var) + { + GPBUtil::checkString($var, True); + $this->status_message = $var; + + return $this; + } + + /** + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have successfully been cancelled + * have [Operation.error][] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * + * Generated from protobuf field bool requested_cancellation = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return bool + */ + public function getRequestedCancellation() + { + return $this->requested_cancellation; + } + + /** + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have successfully been cancelled + * have [Operation.error][] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * + * Generated from protobuf field bool requested_cancellation = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param bool $var + * @return $this + */ + public function setRequestedCancellation($var) + { + GPBUtil::checkBool($var); + $this->requested_cancellation = $var; + + return $this; + } + + /** + * Output only. API version used to start the operation. + * + * Generated from protobuf field string api_version = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getApiVersion() + { + return $this->api_version; + } + + /** + * Output only. API version used to start the operation. + * + * Generated from protobuf field string api_version = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setApiVersion($var) + { + GPBUtil::checkString($var, True); + $this->api_version = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/Repository.php b/Build/src/V2/Repository.php new file mode 100644 index 00000000000..a47b6e0a71b --- /dev/null +++ b/Build/src/V2/Repository.php @@ -0,0 +1,269 @@ +google.devtools.cloudbuild.v2.Repository + */ +class Repository extends \Google\Protobuf\Internal\Message +{ + /** + * Immutable. Resource name of the repository, in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + */ + private $name = ''; + /** + * Required. Git Clone HTTPS URI. + * + * Generated from protobuf field string remote_uri = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $remote_uri = ''; + /** + * Output only. Server assigned timestamp for when the connection was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $create_time = null; + /** + * Output only. Server assigned timestamp for when the connection was updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $update_time = null; + /** + * Allows clients to store small amounts of arbitrary data. + * + * Generated from protobuf field map annotations = 6; + */ + private $annotations; + /** + * 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. + * + * Generated from protobuf field string etag = 7; + */ + private $etag = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Immutable. Resource name of the repository, in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * @type string $remote_uri + * Required. Git Clone HTTPS URI. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. Server assigned timestamp for when the connection was created. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. Server assigned timestamp for when the connection was updated. + * @type array|\Google\Protobuf\Internal\MapField $annotations + * Allows clients to store small amounts of arbitrary data. + * @type string $etag + * 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. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Immutable. Resource name of the repository, in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Immutable. Resource name of the repository, in the format + * `projects/*/locations/*/connections/*/repositories/*`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. Git Clone HTTPS URI. + * + * Generated from protobuf field string remote_uri = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getRemoteUri() + { + return $this->remote_uri; + } + + /** + * Required. Git Clone HTTPS URI. + * + * Generated from protobuf field string remote_uri = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setRemoteUri($var) + { + GPBUtil::checkString($var, True); + $this->remote_uri = $var; + + return $this; + } + + /** + * Output only. Server assigned timestamp for when the connection was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. Server assigned timestamp for when the connection was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. Server assigned timestamp for when the connection was updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + + /** + * Output only. Server assigned timestamp for when the connection was updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Allows clients to store small amounts of arbitrary data. + * + * Generated from protobuf field map annotations = 6; + * @return \Google\Protobuf\Internal\MapField + */ + public function getAnnotations() + { + return $this->annotations; + } + + /** + * Allows clients to store small amounts of arbitrary data. + * + * Generated from protobuf field map annotations = 6; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setAnnotations($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->annotations = $arr; + + return $this; + } + + /** + * 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. + * + * Generated from protobuf field string etag = 7; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * 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. + * + * Generated from protobuf field string etag = 7; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/RepositoryManagerClient.php b/Build/src/V2/RepositoryManagerClient.php new file mode 100644 index 00000000000..cbbd8a468d3 --- /dev/null +++ b/Build/src/V2/RepositoryManagerClient.php @@ -0,0 +1,34 @@ +google.devtools.cloudbuild.v2.RunWorkflowCustomOperationMetadata + */ +class RunWorkflowCustomOperationMetadata extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The time the operation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $create_time = null; + /** + * Output only. The time the operation finished running. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $end_time = null; + /** + * Output only. Name of the verb executed by the operation. + * + * Generated from protobuf field string verb = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $verb = ''; + /** + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have successfully been cancelled + * have [Operation.error][] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * + * Generated from protobuf field bool requested_cancellation = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $requested_cancellation = false; + /** + * Output only. API version used to start the operation. + * + * Generated from protobuf field string api_version = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $api_version = ''; + /** + * Output only. Server-defined resource path for the target of the operation. + * + * Generated from protobuf field string target = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $target = ''; + /** + * Output only. ID of the pipeline run created by RunWorkflow. + * + * Generated from protobuf field string pipeline_run_id = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $pipeline_run_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\Timestamp $create_time + * Output only. The time the operation was created. + * @type \Google\Protobuf\Timestamp $end_time + * Output only. The time the operation finished running. + * @type string $verb + * Output only. Name of the verb executed by the operation. + * @type bool $requested_cancellation + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have successfully been cancelled + * have [Operation.error][] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * @type string $api_version + * Output only. API version used to start the operation. + * @type string $target + * Output only. Server-defined resource path for the target of the operation. + * @type string $pipeline_run_id + * Output only. ID of the pipeline run created by RunWorkflow. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Cloudbuild::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The time the operation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. The time the operation was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. The time the operation finished running. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getEndTime() + { + return $this->end_time; + } + + public function hasEndTime() + { + return isset($this->end_time); + } + + public function clearEndTime() + { + unset($this->end_time); + } + + /** + * Output only. The time the operation finished running. + * + * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setEndTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->end_time = $var; + + return $this; + } + + /** + * Output only. Name of the verb executed by the operation. + * + * Generated from protobuf field string verb = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getVerb() + { + return $this->verb; + } + + /** + * Output only. Name of the verb executed by the operation. + * + * Generated from protobuf field string verb = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setVerb($var) + { + GPBUtil::checkString($var, True); + $this->verb = $var; + + return $this; + } + + /** + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have successfully been cancelled + * have [Operation.error][] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * + * Generated from protobuf field bool requested_cancellation = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return bool + */ + public function getRequestedCancellation() + { + return $this->requested_cancellation; + } + + /** + * Output only. Identifies whether the user has requested cancellation + * of the operation. Operations that have successfully been cancelled + * have [Operation.error][] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`. + * + * Generated from protobuf field bool requested_cancellation = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param bool $var + * @return $this + */ + public function setRequestedCancellation($var) + { + GPBUtil::checkBool($var); + $this->requested_cancellation = $var; + + return $this; + } + + /** + * Output only. API version used to start the operation. + * + * Generated from protobuf field string api_version = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getApiVersion() + { + return $this->api_version; + } + + /** + * Output only. API version used to start the operation. + * + * Generated from protobuf field string api_version = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setApiVersion($var) + { + GPBUtil::checkString($var, True); + $this->api_version = $var; + + return $this; + } + + /** + * Output only. Server-defined resource path for the target of the operation. + * + * Generated from protobuf field string target = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getTarget() + { + return $this->target; + } + + /** + * Output only. Server-defined resource path for the target of the operation. + * + * Generated from protobuf field string target = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setTarget($var) + { + GPBUtil::checkString($var, True); + $this->target = $var; + + return $this; + } + + /** + * Output only. ID of the pipeline run created by RunWorkflow. + * + * Generated from protobuf field string pipeline_run_id = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getPipelineRunId() + { + return $this->pipeline_run_id; + } + + /** + * Output only. ID of the pipeline run created by RunWorkflow. + * + * Generated from protobuf field string pipeline_run_id = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setPipelineRunId($var) + { + GPBUtil::checkString($var, True); + $this->pipeline_run_id = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/ServiceDirectoryConfig.php b/Build/src/V2/ServiceDirectoryConfig.php new file mode 100644 index 00000000000..7a177ccd663 --- /dev/null +++ b/Build/src/V2/ServiceDirectoryConfig.php @@ -0,0 +1,76 @@ +google.devtools.cloudbuild.v2.ServiceDirectoryConfig + */ +class ServiceDirectoryConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The Service Directory service name. + * Format: + * projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}. + * + * Generated from protobuf field string service = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $service = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $service + * Required. The Service Directory service name. + * Format: + * projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The Service Directory service name. + * Format: + * projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}. + * + * Generated from protobuf field string service = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getService() + { + return $this->service; + } + + /** + * Required. The Service Directory service name. + * Format: + * projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}. + * + * Generated from protobuf field string service = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setService($var) + { + GPBUtil::checkString($var, True); + $this->service = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/UpdateConnectionRequest.php b/Build/src/V2/UpdateConnectionRequest.php new file mode 100644 index 00000000000..300c94011b6 --- /dev/null +++ b/Build/src/V2/UpdateConnectionRequest.php @@ -0,0 +1,213 @@ +google.devtools.cloudbuild.v2.UpdateConnectionRequest + */ +class UpdateConnectionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The Connection to update. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.Connection connection = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $connection = null; + /** + * The list of fields to be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + */ + private $update_mask = null; + /** + * If set to true, and the connection is not found a new connection + * will be created. In this situation `update_mask` is ignored. + * The creation will succeed only if the input connection has all the + * necessary information (e.g a github_config with both user_oauth_token and + * installation_id properties). + * + * Generated from protobuf field bool allow_missing = 3; + */ + private $allow_missing = false; + /** + * The current etag of the connection. + * If an etag is provided and does not match the current etag of the + * connection, update will be blocked and an ABORTED error will be returned. + * + * Generated from protobuf field string etag = 4; + */ + private $etag = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Build\V2\Connection $connection + * Required. The Connection to update. + * @type \Google\Protobuf\FieldMask $update_mask + * The list of fields to be updated. + * @type bool $allow_missing + * If set to true, and the connection is not found a new connection + * will be created. In this situation `update_mask` is ignored. + * The creation will succeed only if the input connection has all the + * necessary information (e.g a github_config with both user_oauth_token and + * installation_id properties). + * @type string $etag + * The current etag of the connection. + * If an etag is provided and does not match the current etag of the + * connection, update will be blocked and an ABORTED error will be returned. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Devtools\Cloudbuild\V2\Repositories::initOnce(); + parent::__construct($data); + } + + /** + * Required. The Connection to update. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.Connection connection = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Build\V2\Connection|null + */ + public function getConnection() + { + return $this->connection; + } + + public function hasConnection() + { + return isset($this->connection); + } + + public function clearConnection() + { + unset($this->connection); + } + + /** + * Required. The Connection to update. + * + * Generated from protobuf field .google.devtools.cloudbuild.v2.Connection connection = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Build\V2\Connection $var + * @return $this + */ + public function setConnection($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Build\V2\Connection::class); + $this->connection = $var; + + return $this; + } + + /** + * The list of fields to be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * The list of fields to be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + + /** + * If set to true, and the connection is not found a new connection + * will be created. In this situation `update_mask` is ignored. + * The creation will succeed only if the input connection has all the + * necessary information (e.g a github_config with both user_oauth_token and + * installation_id properties). + * + * Generated from protobuf field bool allow_missing = 3; + * @return bool + */ + public function getAllowMissing() + { + return $this->allow_missing; + } + + /** + * If set to true, and the connection is not found a new connection + * will be created. In this situation `update_mask` is ignored. + * The creation will succeed only if the input connection has all the + * necessary information (e.g a github_config with both user_oauth_token and + * installation_id properties). + * + * Generated from protobuf field bool allow_missing = 3; + * @param bool $var + * @return $this + */ + public function setAllowMissing($var) + { + GPBUtil::checkBool($var); + $this->allow_missing = $var; + + return $this; + } + + /** + * The current etag of the connection. + * If an etag is provided and does not match the current etag of the + * connection, update will be blocked and an ABORTED error will be returned. + * + * Generated from protobuf field string etag = 4; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * The current etag of the connection. + * If an etag is provided and does not match the current etag of the + * connection, update will be blocked and an ABORTED error will be returned. + * + * Generated from protobuf field string etag = 4; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + +} + diff --git a/Build/src/V2/gapic_metadata.json b/Build/src/V2/gapic_metadata.json new file mode 100644 index 00000000000..888351fe8cf --- /dev/null +++ b/Build/src/V2/gapic_metadata.json @@ -0,0 +1,98 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", + "language": "php", + "protoPackage": "google.devtools.cloudbuild.v2", + "libraryPackage": "Google\\Cloud\\Build\\V2", + "services": { + "RepositoryManager": { + "clients": { + "grpc": { + "libraryClient": "RepositoryManagerGapicClient", + "rpcs": { + "BatchCreateRepositories": { + "methods": [ + "batchCreateRepositories" + ] + }, + "CreateConnection": { + "methods": [ + "createConnection" + ] + }, + "CreateRepository": { + "methods": [ + "createRepository" + ] + }, + "DeleteConnection": { + "methods": [ + "deleteConnection" + ] + }, + "DeleteRepository": { + "methods": [ + "deleteRepository" + ] + }, + "FetchLinkableRepositories": { + "methods": [ + "fetchLinkableRepositories" + ] + }, + "FetchReadToken": { + "methods": [ + "fetchReadToken" + ] + }, + "FetchReadWriteToken": { + "methods": [ + "fetchReadWriteToken" + ] + }, + "GetConnection": { + "methods": [ + "getConnection" + ] + }, + "GetRepository": { + "methods": [ + "getRepository" + ] + }, + "ListConnections": { + "methods": [ + "listConnections" + ] + }, + "ListRepositories": { + "methods": [ + "listRepositories" + ] + }, + "UpdateConnection": { + "methods": [ + "updateConnection" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Build/src/V2/resources/repository_manager_client_config.json b/Build/src/V2/resources/repository_manager_client_config.json new file mode 100644 index 00000000000..efd1a489bcc --- /dev/null +++ b/Build/src/V2/resources/repository_manager_client_config.json @@ -0,0 +1,124 @@ +{ + "interfaces": { + "google.devtools.cloudbuild.v2.RepositoryManager": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE" + ], + "no_retry_1_codes": [] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_1_params": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000 + }, + "no_retry_1_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000 + } + }, + "methods": { + "BatchCreateRepositories": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "CreateConnection": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "CreateRepository": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "DeleteConnection": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "DeleteRepository": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "FetchLinkableRepositories": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "FetchReadToken": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "FetchReadWriteToken": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetConnection": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetRepository": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListConnections": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "ListRepositories": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "UpdateConnection": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "TestIamPermissions": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + } + } + } + } +} diff --git a/Build/src/V2/resources/repository_manager_descriptor_config.php b/Build/src/V2/resources/repository_manager_descriptor_config.php new file mode 100644 index 00000000000..6b0c585c037 --- /dev/null +++ b/Build/src/V2/resources/repository_manager_descriptor_config.php @@ -0,0 +1,98 @@ + [ + 'google.devtools.cloudbuild.v2.RepositoryManager' => [ + 'BatchCreateRepositories' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Build\V2\BatchCreateRepositoriesResponse', + 'metadataReturnType' => '\Google\Cloud\Build\V2\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + ], + 'CreateConnection' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Build\V2\Connection', + 'metadataReturnType' => '\Google\Cloud\Build\V2\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + ], + 'CreateRepository' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Build\V2\Repository', + 'metadataReturnType' => '\Google\Cloud\Build\V2\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + ], + 'DeleteConnection' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\Build\V2\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + ], + 'DeleteRepository' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\Build\V2\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + ], + 'UpdateConnection' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Build\V2\Connection', + 'metadataReturnType' => '\Google\Cloud\Build\V2\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + ], + 'FetchLinkableRepositories' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getRepositories', + ], + ], + 'ListConnections' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getConnections', + ], + ], + 'ListRepositories' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getRepositories', + ], + ], + ], + ], +]; diff --git a/Build/src/V2/resources/repository_manager_rest_client_config.php b/Build/src/V2/resources/repository_manager_rest_client_config.php new file mode 100644 index 00000000000..fe081aad713 --- /dev/null +++ b/Build/src/V2/resources/repository_manager_rest_client_config.php @@ -0,0 +1,227 @@ + [ + 'google.devtools.cloudbuild.v2.RepositoryManager' => [ + 'BatchCreateRepositories' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=projects/*/locations/*/connections/*}/repositories:batchCreate', + 'body' => '*', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'CreateConnection' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=projects/*/locations/*}/connections', + 'body' => 'connection', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + 'queryParams' => [ + 'connection_id', + ], + ], + 'CreateRepository' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{parent=projects/*/locations/*/connections/*}/repositories', + 'body' => 'repository', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + 'queryParams' => [ + 'repository_id', + ], + ], + 'DeleteConnection' => [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/connections/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteRepository' => [ + 'method' => 'delete', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/connections/*/repositories/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'FetchLinkableRepositories' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{connection=projects/*/locations/*/connections/*}:fetchLinkableRepositories', + 'placeholders' => [ + 'connection' => [ + 'getters' => [ + 'getConnection', + ], + ], + ], + ], + 'FetchReadToken' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{repository=projects/*/locations/*/connections/*/repositories/*}:accessReadToken', + 'body' => '*', + 'placeholders' => [ + 'repository' => [ + 'getters' => [ + 'getRepository', + ], + ], + ], + ], + 'FetchReadWriteToken' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{repository=projects/*/locations/*/connections/*/repositories/*}:accessReadWriteToken', + 'body' => '*', + 'placeholders' => [ + 'repository' => [ + 'getters' => [ + 'getRepository', + ], + ], + ], + ], + 'GetConnection' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/connections/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetRepository' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/connections/*/repositories/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListConnections' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=projects/*/locations/*}/connections', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'ListRepositories' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{parent=projects/*/locations/*/connections/*}/repositories', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + 'UpdateConnection' => [ + 'method' => 'patch', + 'uriTemplate' => '/v2/{connection.name=projects/*/locations/*/connections/*}', + 'body' => 'connection', + 'placeholders' => [ + 'connection.name' => [ + 'getters' => [ + 'getConnection', + 'getName', + ], + ], + ], + ], + ], + 'google.iam.v1.IAMPolicy' => [ + 'GetIamPolicy' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{resource=projects/*/locations/*/connections/*}:getIamPolicy', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'SetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{resource=projects/*/locations/*/connections/*}:setIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{resource=projects/*/locations/*/connections/*}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/operations/*}:cancel', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v2/{name=projects/*/locations/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/Build/tests/Unit/V2/RepositoryManagerClientTest.php b/Build/tests/Unit/V2/RepositoryManagerClientTest.php new file mode 100644 index 00000000000..654b518f0e7 --- /dev/null +++ b/Build/tests/Unit/V2/RepositoryManagerClientTest.php @@ -0,0 +1,1467 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return RepositoryManagerClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new RepositoryManagerClient($options); + } + + /** @test */ + public function batchCreateRepositoriesTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/batchCreateRepositoriesTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new BatchCreateRepositoriesResponse(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/batchCreateRepositoriesTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $requests = []; + $response = $gapicClient->batchCreateRepositories($formattedParent, $requests); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/BatchCreateRepositories', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getRequests(); + $this->assertProtobufEquals($requests, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/batchCreateRepositoriesTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function batchCreateRepositoriesExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/batchCreateRepositoriesTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $requests = []; + $response = $gapicClient->batchCreateRepositories($formattedParent, $requests); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/batchCreateRepositoriesTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createConnectionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createConnectionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $disabled = true; + $reconciling = false; + $etag = 'etag3123477'; + $expectedResponse = new Connection(); + $expectedResponse->setName($name); + $expectedResponse->setDisabled($disabled); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setEtag($etag); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createConnectionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $connection = new Connection(); + $connectionId = 'connectionId-513204708'; + $response = $gapicClient->createConnection($formattedParent, $connection, $connectionId); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/CreateConnection', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getConnection(); + $this->assertProtobufEquals($connection, $actualValue); + $actualValue = $actualApiRequestObject->getConnectionId(); + $this->assertProtobufEquals($connectionId, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createConnectionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createConnectionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createConnectionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $connection = new Connection(); + $connectionId = 'connectionId-513204708'; + $response = $gapicClient->createConnection($formattedParent, $connection, $connectionId); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createConnectionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createRepositoryTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createRepositoryTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $remoteUri = 'remoteUri1041652211'; + $etag = 'etag3123477'; + $expectedResponse = new Repository(); + $expectedResponse->setName($name); + $expectedResponse->setRemoteUri($remoteUri); + $expectedResponse->setEtag($etag); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createRepositoryTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $repository = new Repository(); + $repositoryRemoteUri = 'repositoryRemoteUri792690460'; + $repository->setRemoteUri($repositoryRemoteUri); + $repositoryId = 'repositoryId1101683248'; + $response = $gapicClient->createRepository($formattedParent, $repository, $repositoryId); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/CreateRepository', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getRepository(); + $this->assertProtobufEquals($repository, $actualValue); + $actualValue = $actualApiRequestObject->getRepositoryId(); + $this->assertProtobufEquals($repositoryId, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createRepositoryTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createRepositoryExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createRepositoryTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $repository = new Repository(); + $repositoryRemoteUri = 'repositoryRemoteUri792690460'; + $repository->setRemoteUri($repositoryRemoteUri); + $repositoryId = 'repositoryId1101683248'; + $response = $gapicClient->createRepository($formattedParent, $repository, $repositoryId); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createRepositoryTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteConnectionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteConnectionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/deleteConnectionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $response = $gapicClient->deleteConnection($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/DeleteConnection', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteConnectionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteConnectionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteConnectionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $response = $gapicClient->deleteConnection($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteConnectionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteRepositoryTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteRepositoryTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/deleteRepositoryTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $gapicClient->repositoryName('[PROJECT]', '[LOCATION]', '[CONNECTION]', '[REPOSITORY]'); + $response = $gapicClient->deleteRepository($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/DeleteRepository', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteRepositoryTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteRepositoryExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteRepositoryTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->repositoryName('[PROJECT]', '[LOCATION]', '[CONNECTION]', '[REPOSITORY]'); + $response = $gapicClient->deleteRepository($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteRepositoryTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function fetchLinkableRepositoriesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $repositoriesElement = new Repository(); + $repositories = [ + $repositoriesElement, + ]; + $expectedResponse = new FetchLinkableRepositoriesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setRepositories($repositories); + $transport->addResponse($expectedResponse); + // Mock request + $formattedConnection = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $response = $gapicClient->fetchLinkableRepositories($formattedConnection); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getRepositories()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/FetchLinkableRepositories', $actualFuncCall); + $actualValue = $actualRequestObject->getConnection(); + $this->assertProtobufEquals($formattedConnection, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function fetchLinkableRepositoriesExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedConnection = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + try { + $gapicClient->fetchLinkableRepositories($formattedConnection); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function fetchReadTokenTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $token = 'token110541305'; + $expectedResponse = new FetchReadTokenResponse(); + $expectedResponse->setToken($token); + $transport->addResponse($expectedResponse); + // Mock request + $formattedRepository = $gapicClient->repositoryName('[PROJECT]', '[LOCATION]', '[CONNECTION]', '[REPOSITORY]'); + $response = $gapicClient->fetchReadToken($formattedRepository); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/FetchReadToken', $actualFuncCall); + $actualValue = $actualRequestObject->getRepository(); + $this->assertProtobufEquals($formattedRepository, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function fetchReadTokenExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedRepository = $gapicClient->repositoryName('[PROJECT]', '[LOCATION]', '[CONNECTION]', '[REPOSITORY]'); + try { + $gapicClient->fetchReadToken($formattedRepository); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function fetchReadWriteTokenTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $token = 'token110541305'; + $expectedResponse = new FetchReadWriteTokenResponse(); + $expectedResponse->setToken($token); + $transport->addResponse($expectedResponse); + // Mock request + $formattedRepository = $gapicClient->repositoryName('[PROJECT]', '[LOCATION]', '[CONNECTION]', '[REPOSITORY]'); + $response = $gapicClient->fetchReadWriteToken($formattedRepository); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/FetchReadWriteToken', $actualFuncCall); + $actualValue = $actualRequestObject->getRepository(); + $this->assertProtobufEquals($formattedRepository, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function fetchReadWriteTokenExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedRepository = $gapicClient->repositoryName('[PROJECT]', '[LOCATION]', '[CONNECTION]', '[REPOSITORY]'); + try { + $gapicClient->fetchReadWriteToken($formattedRepository); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getConnectionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $disabled = true; + $reconciling = false; + $etag = 'etag3123477'; + $expectedResponse = new Connection(); + $expectedResponse->setName($name2); + $expectedResponse->setDisabled($disabled); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $response = $gapicClient->getConnection($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/GetConnection', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getConnectionExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + try { + $gapicClient->getConnection($formattedName); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getRepositoryTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $remoteUri = 'remoteUri1041652211'; + $etag = 'etag3123477'; + $expectedResponse = new Repository(); + $expectedResponse->setName($name2); + $expectedResponse->setRemoteUri($remoteUri); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->repositoryName('[PROJECT]', '[LOCATION]', '[CONNECTION]', '[REPOSITORY]'); + $response = $gapicClient->getRepository($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/GetRepository', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getRepositoryExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->repositoryName('[PROJECT]', '[LOCATION]', '[CONNECTION]', '[REPOSITORY]'); + try { + $gapicClient->getRepository($formattedName); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listConnectionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $connectionsElement = new Connection(); + $connections = [ + $connectionsElement, + ]; + $expectedResponse = new ListConnectionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setConnections($connections); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $response = $gapicClient->listConnections($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getConnections()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/ListConnections', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listConnectionsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + try { + $gapicClient->listConnections($formattedParent); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listRepositoriesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $repositoriesElement = new Repository(); + $repositories = [ + $repositoriesElement, + ]; + $expectedResponse = new ListRepositoriesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setRepositories($repositories); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + $response = $gapicClient->listRepositories($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getRepositories()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/ListRepositories', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listRepositoriesExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]'); + try { + $gapicClient->listRepositories($formattedParent); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateConnectionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateConnectionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $disabled = true; + $reconciling = false; + $etag2 = 'etag2-1293302904'; + $expectedResponse = new Connection(); + $expectedResponse->setName($name); + $expectedResponse->setDisabled($disabled); + $expectedResponse->setReconciling($reconciling); + $expectedResponse->setEtag($etag2); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateConnectionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $connection = new Connection(); + $response = $gapicClient->updateConnection($connection); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.devtools.cloudbuild.v2.RepositoryManager/UpdateConnection', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getConnection(); + $this->assertProtobufEquals($connection, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateConnectionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateConnectionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateConnectionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $operationsTransport->addResponse(null, $status); + // Mock request + $connection = new Connection(); + $response = $gapicClient->updateConnection($connection); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateConnectionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function getIamPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $response = $gapicClient->getIamPolicy($resource); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.iam.v1.IAMPolicy/GetIamPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getIamPolicyExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $resource = 'resource-341064690'; + try { + $gapicClient->getIamPolicy($resource); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function setIamPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $policy = new Policy(); + $response = $gapicClient->setIamPolicy($resource, $policy); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.iam.v1.IAMPolicy/SetIamPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPolicy(); + $this->assertProtobufEquals($policy, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function setIamPolicyExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $resource = 'resource-341064690'; + $policy = new Policy(); + try { + $gapicClient->setIamPolicy($resource, $policy); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function testIamPermissionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new TestIamPermissionsResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $permissions = []; + $response = $gapicClient->testIamPermissions($resource, $permissions); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.iam.v1.IAMPolicy/TestIamPermissions', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPermissions(); + $this->assertProtobufEquals($permissions, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function testIamPermissionsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $resource = 'resource-341064690'; + $permissions = []; + try { + $gapicClient->testIamPermissions($resource, $permissions); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } +}