From 9f9880384f6118f55bf60c09599ddc2e7afc367d Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 28 Sep 2024 03:56:19 +0000 Subject: [PATCH] feat: added support for deploy policies (#7711) docs: Minor documentation updates PiperOrigin-RevId: 679600689 Source-Link: https://github.com/googleapis/googleapis/commit/bd4f3686c1831554b71129898e20f2cdb7aeac49 Source-Link: https://github.com/googleapis/googleapis-gen/commit/12a2d22bf1bda85ba9bed1fa60484306a2e55781 Copy-Tag: eyJwIjoiRGVwbG95Ly5Pd2xCb3QueWFtbCIsImgiOiIxMmEyZDIyYmYxYmRhODViYTliZWQxZmE2MDQ4NDMwNmEyZTU1NzgxIn0= --- Deploy/metadata/V1/CloudDeploy.php | Bin 43461 -> 48994 bytes Deploy/metadata/V1/LogEnums.php | Bin 960 -> 995 bytes Deploy/src/V1/AdvanceRolloutRequest.php | 38 ++ Deploy/src/V1/ApproveRolloutRequest.php | 38 ++ Deploy/src/V1/AutomationRun.php | 48 ++ Deploy/src/V1/CancelRolloutRequest.php | 38 ++ Deploy/src/V1/Client/CloudDeployClient.php | 161 +++++ Deploy/src/V1/CreateReleaseRequest.php | 38 ++ Deploy/src/V1/CreateRolloutRequest.php | 38 ++ Deploy/src/V1/DeliveryPipelineAttribute.php | 20 +- Deploy/src/V1/DeployPolicy.php | 2 +- Deploy/src/V1/IgnoreJobRequest.php | 38 ++ Deploy/src/V1/OneTimeWindow.php | 210 +++++++ Deploy/src/V1/PolicyRule.php | 26 +- Deploy/src/V1/RetryJobRequest.php | 38 ++ Deploy/src/V1/RollbackTargetRequest.php | 38 ++ Deploy/src/V1/RolloutRestriction.php | 191 ++++++ .../V1/RolloutRestriction/RolloutActions.php | 104 ++++ Deploy/src/V1/TargetAttribute.php | 3 +- Deploy/src/V1/TerminateJobRunRequest.php | 38 ++ Deploy/src/V1/TimeWindows.php | 141 +++++ Deploy/src/V1/Type.php | 7 + Deploy/src/V1/WeeklyWindow.php | 176 ++++++ Deploy/src/V1/gapic_metadata.json | 25 + .../resources/cloud_deploy_client_config.json | 25 + .../cloud_deploy_descriptor_config.php | 91 +++ .../cloud_deploy_rest_client_config.php | 64 ++ .../Unit/V1/Client/CloudDeployClientTest.php | 571 ++++++++++++++++++ 28 files changed, 2180 insertions(+), 27 deletions(-) create mode 100644 Deploy/src/V1/OneTimeWindow.php create mode 100644 Deploy/src/V1/RolloutRestriction.php create mode 100644 Deploy/src/V1/RolloutRestriction/RolloutActions.php create mode 100644 Deploy/src/V1/TimeWindows.php create mode 100644 Deploy/src/V1/WeeklyWindow.php diff --git a/Deploy/metadata/V1/CloudDeploy.php b/Deploy/metadata/V1/CloudDeploy.php index c9a2be1637a25a21084a49feb11f0d9d9b5d2800..a0e8102a4107e6df69d6e842de78be3cd6d0493f 100644 GIT binary patch delta 3590 zcmbtXZERCj81~$D?RvV8yF+R3K9H>r7(-iE5P^X1t}Rd;ZRx%Q3{6?jW~KDj-n-3W z%%bj3}sS^UCJ zf0R~Qhrx!H)^SA{&tkt;%ws>b;3s|gf}$zrO>GXOq}0S*!cj}phKNd^Ej8rX{ojybk(AMx`eZMR8tD7R7W0mtXiYfNnll(D2(EP@@Ajq zsw|+5u%EAZy2cIapcQMWamh)+9puc;bbk=qBe_ZC5H27OTo#EA z$LN{jj zD`XB%XnJG-ZG|>1RT#&bBXsXEU?|it$XI{>tGB z4uVj~q$TFZfp%9aCD6Wb2DZ)lrD$PtC2*=U3E_NpQ3Nh4DA}wsp(P7grOZZI*~vAf zo%Dw7F&fj{+Rj`0Y|zTet(tj+KmsWduER|7fYYGKW@y4+~x z3hF`97PqH#@2X^B#(~Y`;`(OtSIE|5@Zu{wmbocEdJn8)7biKD$)%MkRkD&7+Haj^ z7jlHJ=zP3y1K40bj#k3fM6AC*HZ+)&gRCnCs(Q!??Q&>Xjt0ZDjo3##o`?;HMS-T> z7G&%FqDB9m2+MWU64T-2u2`Q~gX*Cp5gttJ)jw^h4%RZ4eRA+V(T-eD z91JIRN22sFGe`_Y#aizN06GoyksCVn0FNj+%qz_^9D*WUNt%M^gk%)1EVfP-3w$c8q84KgI))kt7etjBg4btoM$>Mt(DfGfGw$ zU=)W^URTcKNJDOJEZt=yG#4heJ)AwGw;Ry4GTRzT6D zp%rJmS9)Q+X2iNY)eJ=Fu$V(yIyZ(HO;#M;b=PwMwk(FF z=II#5Xd7%a=7+k`%TKSZaT>q3${!ek?j6`jsW?aIUxrqa?mb}@W(D$2@aj@858F*% z9?ylgEE7Hz$fc3*y8rq8ax;|I?(YP`c|b1ieQ+r|9%PKN^HWu?y7x-} z#mIP0DPZ!|esw7q)l0-^y_E>vW(m;-EJ-OMkp*uhx zf1{(@95{tW7bw<3Au9(fp0(D8=KqLfFzGnEdaY@N>L=GcZ}5A$JYDqYHXuFMoo1Kl zT>u-a1P}T2%wB$~W?3chITdW_q(QZ`&aZpr?`2)`D^6%!O=c%FuF^NBeslc|&`zI8 delta 226 zcmaF#kLl=TrVa0yC&#hqGaWm%xt}GBakD&|rwG$}rp;MW`iz@jOFt5yY-TZK^9tK7 z+?%_6`&gJBFiw^Vda&6i*h-k`JLBYzv>Tf@r7JTsW=y`GkuiB|JkOTaTdFTW^t zvVKnSWPuzp#;VC0IaQm#j(Wz;uR2w^nHITh7Mv;~ KxVdQ62N3|#f>w3_ diff --git a/Deploy/metadata/V1/LogEnums.php b/Deploy/metadata/V1/LogEnums.php index eb87553c34e10d6ac3192967af9a21f27c4559b0..27693e1cb5e534cbe97029b803904d3dee091b36 100644 GIT binary patch delta 59 zcmX@W{+NBk4MxTzlW#IQF->EdEX#C3Ns&u7Br?D?-o-V*$3HSYz~9HyIWpcg%+V** PF~rl~Pk>|c8>TA&Tw)WJ delta 24 gcmaFNet><$4MxU=lW#IQF@0v7EX#CZvHstring phase_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ protected $phase_id = ''; + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $override_deploy_policy; /** * @param string $name Required. Name of the Rollout. Format is @@ -57,6 +64,9 @@ public static function build(string $name, string $phaseId): self * `projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}`. * @type string $phase_id * Required. The phase ID to advance the `Rollout` to. + * @type array|\Google\Protobuf\Internal\RepeatedField $override_deploy_policy + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. * } */ public function __construct($data = NULL) { @@ -118,5 +128,33 @@ public function setPhaseId($var) return $this; } + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOverrideDeployPolicy() + { + return $this->override_deploy_policy; + } + + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOverrideDeployPolicy($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->override_deploy_policy = $arr; + + return $this; + } + } diff --git a/Deploy/src/V1/ApproveRolloutRequest.php b/Deploy/src/V1/ApproveRolloutRequest.php index 4f881df0b1c2..c0e44d90c61f 100644 --- a/Deploy/src/V1/ApproveRolloutRequest.php +++ b/Deploy/src/V1/ApproveRolloutRequest.php @@ -28,6 +28,13 @@ class ApproveRolloutRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field bool approved = 2 [(.google.api.field_behavior) = REQUIRED]; */ protected $approved = false; + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $override_deploy_policy; /** * @param string $name Required. Name of the Rollout. Format is @@ -55,6 +62,9 @@ public static function build(string $name): self * `projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}`. * @type bool $approved * Required. True = approve; false = reject + * @type array|\Google\Protobuf\Internal\RepeatedField $override_deploy_policy + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. * } */ public function __construct($data = NULL) { @@ -116,5 +126,33 @@ public function setApproved($var) return $this; } + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOverrideDeployPolicy() + { + return $this->override_deploy_policy; + } + + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOverrideDeployPolicy($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->override_deploy_policy = $arr; + + return $this; + } + } diff --git a/Deploy/src/V1/AutomationRun.php b/Deploy/src/V1/AutomationRun.php index 3db70ad3d274..8e58a483df78 100644 --- a/Deploy/src/V1/AutomationRun.php +++ b/Deploy/src/V1/AutomationRun.php @@ -80,6 +80,13 @@ class AutomationRun extends \Google\Protobuf\Internal\Message * Generated from protobuf field string state_description = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ protected $state_description = ''; + /** + * Output only. Contains information about what policies prevented the + * `AutomationRun` from proceeding. + * + * Generated from protobuf field .google.cloud.deploy.v1.PolicyViolation policy_violation = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $policy_violation = null; /** * Output only. Time the `AutomationRun` expires. An `AutomationRun` expires * after 14 days from its creation date. @@ -141,6 +148,9 @@ class AutomationRun extends \Google\Protobuf\Internal\Message * @type string $state_description * Output only. Explains the current state of the `AutomationRun`. Present * only when an explanation is needed. + * @type \Google\Cloud\Deploy\V1\PolicyViolation $policy_violation + * Output only. Contains information about what policies prevented the + * `AutomationRun` from proceeding. * @type \Google\Protobuf\Timestamp $expire_time * Output only. Time the `AutomationRun` expires. An `AutomationRun` expires * after 14 days from its creation date. @@ -446,6 +456,44 @@ public function setStateDescription($var) return $this; } + /** + * Output only. Contains information about what policies prevented the + * `AutomationRun` from proceeding. + * + * Generated from protobuf field .google.cloud.deploy.v1.PolicyViolation policy_violation = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\Deploy\V1\PolicyViolation|null + */ + public function getPolicyViolation() + { + return $this->policy_violation; + } + + public function hasPolicyViolation() + { + return isset($this->policy_violation); + } + + public function clearPolicyViolation() + { + unset($this->policy_violation); + } + + /** + * Output only. Contains information about what policies prevented the + * `AutomationRun` from proceeding. + * + * Generated from protobuf field .google.cloud.deploy.v1.PolicyViolation policy_violation = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\Deploy\V1\PolicyViolation $var + * @return $this + */ + public function setPolicyViolation($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Deploy\V1\PolicyViolation::class); + $this->policy_violation = $var; + + return $this; + } + /** * Output only. Time the `AutomationRun` expires. An `AutomationRun` expires * after 14 days from its creation date. diff --git a/Deploy/src/V1/CancelRolloutRequest.php b/Deploy/src/V1/CancelRolloutRequest.php index 3ae1d6f52a6f..540f9ddb48dd 100644 --- a/Deploy/src/V1/CancelRolloutRequest.php +++ b/Deploy/src/V1/CancelRolloutRequest.php @@ -22,6 +22,13 @@ class CancelRolloutRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ protected $name = ''; + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $override_deploy_policy; /** * @param string $name Required. Name of the Rollout. Format is @@ -47,6 +54,9 @@ public static function build(string $name): self * @type string $name * Required. Name of the Rollout. Format is * `projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}`. + * @type array|\Google\Protobuf\Internal\RepeatedField $override_deploy_policy + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. * } */ public function __construct($data = NULL) { @@ -82,5 +92,33 @@ public function setName($var) return $this; } + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOverrideDeployPolicy() + { + return $this->override_deploy_policy; + } + + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOverrideDeployPolicy($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->override_deploy_policy = $arr; + + return $this; + } + } diff --git a/Deploy/src/V1/Client/CloudDeployClient.php b/Deploy/src/V1/Client/CloudDeployClient.php index 6bb7d99f935d..48adb7913db0 100644 --- a/Deploy/src/V1/Client/CloudDeployClient.php +++ b/Deploy/src/V1/Client/CloudDeployClient.php @@ -50,6 +50,7 @@ use Google\Cloud\Deploy\V1\CreateAutomationRequest; use Google\Cloud\Deploy\V1\CreateCustomTargetTypeRequest; use Google\Cloud\Deploy\V1\CreateDeliveryPipelineRequest; +use Google\Cloud\Deploy\V1\CreateDeployPolicyRequest; use Google\Cloud\Deploy\V1\CreateReleaseRequest; use Google\Cloud\Deploy\V1\CreateRolloutRequest; use Google\Cloud\Deploy\V1\CreateTargetRequest; @@ -57,13 +58,16 @@ use Google\Cloud\Deploy\V1\DeleteAutomationRequest; use Google\Cloud\Deploy\V1\DeleteCustomTargetTypeRequest; use Google\Cloud\Deploy\V1\DeleteDeliveryPipelineRequest; +use Google\Cloud\Deploy\V1\DeleteDeployPolicyRequest; use Google\Cloud\Deploy\V1\DeleteTargetRequest; use Google\Cloud\Deploy\V1\DeliveryPipeline; +use Google\Cloud\Deploy\V1\DeployPolicy; use Google\Cloud\Deploy\V1\GetAutomationRequest; use Google\Cloud\Deploy\V1\GetAutomationRunRequest; use Google\Cloud\Deploy\V1\GetConfigRequest; use Google\Cloud\Deploy\V1\GetCustomTargetTypeRequest; use Google\Cloud\Deploy\V1\GetDeliveryPipelineRequest; +use Google\Cloud\Deploy\V1\GetDeployPolicyRequest; use Google\Cloud\Deploy\V1\GetJobRunRequest; use Google\Cloud\Deploy\V1\GetReleaseRequest; use Google\Cloud\Deploy\V1\GetRolloutRequest; @@ -75,6 +79,7 @@ use Google\Cloud\Deploy\V1\ListAutomationsRequest; use Google\Cloud\Deploy\V1\ListCustomTargetTypesRequest; use Google\Cloud\Deploy\V1\ListDeliveryPipelinesRequest; +use Google\Cloud\Deploy\V1\ListDeployPoliciesRequest; use Google\Cloud\Deploy\V1\ListJobRunsRequest; use Google\Cloud\Deploy\V1\ListReleasesRequest; use Google\Cloud\Deploy\V1\ListRolloutsRequest; @@ -91,6 +96,7 @@ use Google\Cloud\Deploy\V1\UpdateAutomationRequest; use Google\Cloud\Deploy\V1\UpdateCustomTargetTypeRequest; use Google\Cloud\Deploy\V1\UpdateDeliveryPipelineRequest; +use Google\Cloud\Deploy\V1\UpdateDeployPolicyRequest; use Google\Cloud\Deploy\V1\UpdateTargetRequest; use Google\Cloud\Iam\V1\GetIamPolicyRequest; use Google\Cloud\Iam\V1\Policy; @@ -124,18 +130,21 @@ * @method PromiseInterface createAutomationAsync(CreateAutomationRequest $request, array $optionalArgs = []) * @method PromiseInterface createCustomTargetTypeAsync(CreateCustomTargetTypeRequest $request, array $optionalArgs = []) * @method PromiseInterface createDeliveryPipelineAsync(CreateDeliveryPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDeployPolicyAsync(CreateDeployPolicyRequest $request, array $optionalArgs = []) * @method PromiseInterface createReleaseAsync(CreateReleaseRequest $request, array $optionalArgs = []) * @method PromiseInterface createRolloutAsync(CreateRolloutRequest $request, array $optionalArgs = []) * @method PromiseInterface createTargetAsync(CreateTargetRequest $request, array $optionalArgs = []) * @method PromiseInterface deleteAutomationAsync(DeleteAutomationRequest $request, array $optionalArgs = []) * @method PromiseInterface deleteCustomTargetTypeAsync(DeleteCustomTargetTypeRequest $request, array $optionalArgs = []) * @method PromiseInterface deleteDeliveryPipelineAsync(DeleteDeliveryPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDeployPolicyAsync(DeleteDeployPolicyRequest $request, array $optionalArgs = []) * @method PromiseInterface deleteTargetAsync(DeleteTargetRequest $request, array $optionalArgs = []) * @method PromiseInterface getAutomationAsync(GetAutomationRequest $request, array $optionalArgs = []) * @method PromiseInterface getAutomationRunAsync(GetAutomationRunRequest $request, array $optionalArgs = []) * @method PromiseInterface getConfigAsync(GetConfigRequest $request, array $optionalArgs = []) * @method PromiseInterface getCustomTargetTypeAsync(GetCustomTargetTypeRequest $request, array $optionalArgs = []) * @method PromiseInterface getDeliveryPipelineAsync(GetDeliveryPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDeployPolicyAsync(GetDeployPolicyRequest $request, array $optionalArgs = []) * @method PromiseInterface getJobRunAsync(GetJobRunRequest $request, array $optionalArgs = []) * @method PromiseInterface getReleaseAsync(GetReleaseRequest $request, array $optionalArgs = []) * @method PromiseInterface getRolloutAsync(GetRolloutRequest $request, array $optionalArgs = []) @@ -145,6 +154,7 @@ * @method PromiseInterface listAutomationsAsync(ListAutomationsRequest $request, array $optionalArgs = []) * @method PromiseInterface listCustomTargetTypesAsync(ListCustomTargetTypesRequest $request, array $optionalArgs = []) * @method PromiseInterface listDeliveryPipelinesAsync(ListDeliveryPipelinesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDeployPoliciesAsync(ListDeployPoliciesRequest $request, array $optionalArgs = []) * @method PromiseInterface listJobRunsAsync(ListJobRunsRequest $request, array $optionalArgs = []) * @method PromiseInterface listReleasesAsync(ListReleasesRequest $request, array $optionalArgs = []) * @method PromiseInterface listRolloutsAsync(ListRolloutsRequest $request, array $optionalArgs = []) @@ -155,6 +165,7 @@ * @method PromiseInterface updateAutomationAsync(UpdateAutomationRequest $request, array $optionalArgs = []) * @method PromiseInterface updateCustomTargetTypeAsync(UpdateCustomTargetTypeRequest $request, array $optionalArgs = []) * @method PromiseInterface updateDeliveryPipelineAsync(UpdateDeliveryPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDeployPolicyAsync(UpdateDeployPolicyRequest $request, array $optionalArgs = []) * @method PromiseInterface updateTargetAsync(UpdateTargetRequest $request, array $optionalArgs = []) * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) @@ -403,6 +414,25 @@ public static function deliveryPipelineName(string $project, string $location, s ]); } + /** + * Formats a string containing the fully-qualified path to represent a + * deploy_policy resource. + * + * @param string $project + * @param string $location + * @param string $deployPolicy + * + * @return string The formatted deploy_policy resource. + */ + public static function deployPolicyName(string $project, string $location, string $deployPolicy): string + { + return self::getPathTemplate('deployPolicy')->render([ + 'project' => $project, + 'location' => $location, + 'deploy_policy' => $deployPolicy, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a job * resource. @@ -635,6 +665,7 @@ public static function workerPoolName(string $project, string $location, string * - config: projects/{project}/locations/{location}/config * - customTargetType: projects/{project}/locations/{location}/customTargetTypes/{custom_target_type} * - deliveryPipeline: projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline} + * - deployPolicy: projects/{project}/locations/{location}/deployPolicies/{deploy_policy} * - job: projects/{project}/locations/{location}/jobs/{job} * - jobRun: projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}/releases/{release}/rollouts/{rollout}/jobRuns/{job_run} * - location: projects/{project}/locations/{location} @@ -953,6 +984,32 @@ public function createDeliveryPipeline( return $this->startApiCall('CreateDeliveryPipeline', $request, $callOptions)->wait(); } + /** + * Creates a new DeployPolicy in a given project and location. + * + * The async variant is {@see CloudDeployClient::createDeployPolicyAsync()} . + * + * @example samples/V1/CloudDeployClient/create_deploy_policy.php + * + * @param CreateDeployPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDeployPolicy(CreateDeployPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDeployPolicy', $request, $callOptions)->wait(); + } + /** * Creates a new Release in a given project and location. * @@ -1113,6 +1170,32 @@ public function deleteDeliveryPipeline( return $this->startApiCall('DeleteDeliveryPipeline', $request, $callOptions)->wait(); } + /** + * Deletes a single DeployPolicy. + * + * The async variant is {@see CloudDeployClient::deleteDeployPolicyAsync()} . + * + * @example samples/V1/CloudDeployClient/delete_deploy_policy.php + * + * @param DeleteDeployPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDeployPolicy(DeleteDeployPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDeployPolicy', $request, $callOptions)->wait(); + } + /** * Deletes a single Target. * @@ -1269,6 +1352,32 @@ public function getDeliveryPipeline(GetDeliveryPipelineRequest $request, array $ return $this->startApiCall('GetDeliveryPipeline', $request, $callOptions)->wait(); } + /** + * Gets details of a single DeployPolicy. + * + * The async variant is {@see CloudDeployClient::getDeployPolicyAsync()} . + * + * @example samples/V1/CloudDeployClient/get_deploy_policy.php + * + * @param GetDeployPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeployPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDeployPolicy(GetDeployPolicyRequest $request, array $callOptions = []): DeployPolicy + { + return $this->startApiCall('GetDeployPolicy', $request, $callOptions)->wait(); + } + /** * Gets details of a single JobRun. * @@ -1507,6 +1616,32 @@ public function listDeliveryPipelines( return $this->startApiCall('ListDeliveryPipelines', $request, $callOptions); } + /** + * Lists DeployPolicies in a given project and location. + * + * The async variant is {@see CloudDeployClient::listDeployPoliciesAsync()} . + * + * @example samples/V1/CloudDeployClient/list_deploy_policies.php + * + * @param ListDeployPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDeployPolicies(ListDeployPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDeployPolicies', $request, $callOptions); + } + /** * Lists JobRuns in a given project and location. * @@ -1771,6 +1906,32 @@ public function updateDeliveryPipeline( return $this->startApiCall('UpdateDeliveryPipeline', $request, $callOptions)->wait(); } + /** + * Updates the parameters of a single DeployPolicy. + * + * The async variant is {@see CloudDeployClient::updateDeployPolicyAsync()} . + * + * @example samples/V1/CloudDeployClient/update_deploy_policy.php + * + * @param UpdateDeployPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDeployPolicy(UpdateDeployPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDeployPolicy', $request, $callOptions)->wait(); + } + /** * Updates the parameters of a single Target. * diff --git a/Deploy/src/V1/CreateReleaseRequest.php b/Deploy/src/V1/CreateReleaseRequest.php index 27e81a1e44db..06f287273d32 100644 --- a/Deploy/src/V1/CreateReleaseRequest.php +++ b/Deploy/src/V1/CreateReleaseRequest.php @@ -58,6 +58,13 @@ class CreateReleaseRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field bool validate_only = 5 [(.google.api.field_behavior) = OPTIONAL]; */ protected $validate_only = false; + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 6 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $override_deploy_policy; /** * @param string $parent Required. The parent collection in which the `Release` is created. @@ -108,6 +115,9 @@ public static function build(string $parent, \Google\Cloud\Deploy\V1\Release $re * @type bool $validate_only * Optional. If set to true, the request is validated and the user is provided * with an expected result, but no actual change is made. + * @type array|\Google\Protobuf\Internal\RepeatedField $override_deploy_policy + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. * } */ public function __construct($data = NULL) { @@ -281,5 +291,33 @@ public function setValidateOnly($var) return $this; } + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 6 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOverrideDeployPolicy() + { + return $this->override_deploy_policy; + } + + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 6 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOverrideDeployPolicy($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->override_deploy_policy = $arr; + + return $this; + } + } diff --git a/Deploy/src/V1/CreateRolloutRequest.php b/Deploy/src/V1/CreateRolloutRequest.php index 30f1bc25d5d7..f8ce1968ee03 100644 --- a/Deploy/src/V1/CreateRolloutRequest.php +++ b/Deploy/src/V1/CreateRolloutRequest.php @@ -58,6 +58,13 @@ class CreateRolloutRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field bool validate_only = 5 [(.google.api.field_behavior) = OPTIONAL]; */ protected $validate_only = false; + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 6 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $override_deploy_policy; /** * Optional. The starting phase ID for the `Rollout`. If empty the `Rollout` * will start at the first phase. @@ -115,6 +122,9 @@ public static function build(string $parent, \Google\Cloud\Deploy\V1\Rollout $ro * @type bool $validate_only * Optional. If set to true, the request is validated and the user is provided * with an expected result, but no actual change is made. + * @type array|\Google\Protobuf\Internal\RepeatedField $override_deploy_policy + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. * @type string $starting_phase_id * Optional. The starting phase ID for the `Rollout`. If empty the `Rollout` * will start at the first phase. @@ -291,6 +301,34 @@ public function setValidateOnly($var) return $this; } + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 6 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOverrideDeployPolicy() + { + return $this->override_deploy_policy; + } + + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 6 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOverrideDeployPolicy($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->override_deploy_policy = $arr; + + return $this; + } + /** * Optional. The starting phase ID for the `Rollout`. If empty the `Rollout` * will start at the first phase. diff --git a/Deploy/src/V1/DeliveryPipelineAttribute.php b/Deploy/src/V1/DeliveryPipelineAttribute.php index bf43a26e2ea7..ef1ee797ee72 100644 --- a/Deploy/src/V1/DeliveryPipelineAttribute.php +++ b/Deploy/src/V1/DeliveryPipelineAttribute.php @@ -18,9 +18,8 @@ class DeliveryPipelineAttribute extends \Google\Protobuf\Internal\Message /** * ID of the `DeliveryPipeline`. The value of this field could be one of the * following: - * * The last segment of a pipeline name. It only needs the ID to determine - * which pipeline is being referred to - * * "*", all delivery pipelines in a location. + * * The last segment of a pipeline name + * * "*", all delivery pipelines in a location * * Generated from protobuf field string id = 1; */ @@ -41,9 +40,8 @@ class DeliveryPipelineAttribute extends \Google\Protobuf\Internal\Message * @type string $id * ID of the `DeliveryPipeline`. The value of this field could be one of the * following: - * * The last segment of a pipeline name. It only needs the ID to determine - * which pipeline is being referred to - * * "*", all delivery pipelines in a location. + * * The last segment of a pipeline name + * * "*", all delivery pipelines in a location * @type array|\Google\Protobuf\Internal\MapField $labels * DeliveryPipeline labels. * } @@ -56,9 +54,8 @@ public function __construct($data = NULL) { /** * ID of the `DeliveryPipeline`. The value of this field could be one of the * following: - * * The last segment of a pipeline name. It only needs the ID to determine - * which pipeline is being referred to - * * "*", all delivery pipelines in a location. + * * The last segment of a pipeline name + * * "*", all delivery pipelines in a location * * Generated from protobuf field string id = 1; * @return string @@ -71,9 +68,8 @@ public function getId() /** * ID of the `DeliveryPipeline`. The value of this field could be one of the * following: - * * The last segment of a pipeline name. It only needs the ID to determine - * which pipeline is being referred to - * * "*", all delivery pipelines in a location. + * * The last segment of a pipeline name + * * "*", all delivery pipelines in a location * * Generated from protobuf field string id = 1; * @param string $var diff --git a/Deploy/src/V1/DeployPolicy.php b/Deploy/src/V1/DeployPolicy.php index 3dd108745826..0076a6bc9779 100644 --- a/Deploy/src/V1/DeployPolicy.php +++ b/Deploy/src/V1/DeployPolicy.php @@ -10,7 +10,7 @@ /** * A `DeployPolicy` resource in the Cloud Deploy API. - * A `DeployPolicy` inhibits manual or automation driven actions within a + * A `DeployPolicy` inhibits manual or automation-driven actions within a * Delivery Pipeline or Target. * * Generated from protobuf message google.cloud.deploy.v1.DeployPolicy diff --git a/Deploy/src/V1/IgnoreJobRequest.php b/Deploy/src/V1/IgnoreJobRequest.php index 094701d85774..d191c4db127a 100644 --- a/Deploy/src/V1/IgnoreJobRequest.php +++ b/Deploy/src/V1/IgnoreJobRequest.php @@ -34,6 +34,13 @@ class IgnoreJobRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field string job_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ protected $job_id = ''; + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 4 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $override_deploy_policy; /** * @param string $rollout Required. Name of the Rollout. Format is @@ -67,6 +74,9 @@ public static function build(string $rollout, string $phaseId, string $jobId): s * Required. The phase ID the Job to ignore belongs to. * @type string $job_id * Required. The job ID for the Job to ignore. + * @type array|\Google\Protobuf\Internal\RepeatedField $override_deploy_policy + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. * } */ public function __construct($data = NULL) { @@ -154,5 +164,33 @@ public function setJobId($var) return $this; } + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 4 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOverrideDeployPolicy() + { + return $this->override_deploy_policy; + } + + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 4 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOverrideDeployPolicy($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->override_deploy_policy = $arr; + + return $this; + } + } diff --git a/Deploy/src/V1/OneTimeWindow.php b/Deploy/src/V1/OneTimeWindow.php new file mode 100644 index 000000000000..46893dbebc01 --- /dev/null +++ b/Deploy/src/V1/OneTimeWindow.php @@ -0,0 +1,210 @@ +google.cloud.deploy.v1.OneTimeWindow + */ +class OneTimeWindow extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Start date. + * + * Generated from protobuf field .google.type.Date start_date = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $start_date = null; + /** + * Required. Start time (inclusive). Use 00:00 for the beginning of the day. + * + * Generated from protobuf field .google.type.TimeOfDay start_time = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $start_time = null; + /** + * Required. End date. + * + * Generated from protobuf field .google.type.Date end_date = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $end_date = null; + /** + * Required. End time (exclusive). You may use 24:00 for the end of the day. + * + * Generated from protobuf field .google.type.TimeOfDay end_time = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $end_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Type\Date $start_date + * Required. Start date. + * @type \Google\Type\TimeOfDay $start_time + * Required. Start time (inclusive). Use 00:00 for the beginning of the day. + * @type \Google\Type\Date $end_date + * Required. End date. + * @type \Google\Type\TimeOfDay $end_time + * Required. End time (exclusive). You may use 24:00 for the end of the day. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Deploy\V1\CloudDeploy::initOnce(); + parent::__construct($data); + } + + /** + * Required. Start date. + * + * Generated from protobuf field .google.type.Date start_date = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Type\Date|null + */ + public function getStartDate() + { + return $this->start_date; + } + + public function hasStartDate() + { + return isset($this->start_date); + } + + public function clearStartDate() + { + unset($this->start_date); + } + + /** + * Required. Start date. + * + * Generated from protobuf field .google.type.Date start_date = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Type\Date $var + * @return $this + */ + public function setStartDate($var) + { + GPBUtil::checkMessage($var, \Google\Type\Date::class); + $this->start_date = $var; + + return $this; + } + + /** + * Required. Start time (inclusive). Use 00:00 for the beginning of the day. + * + * Generated from protobuf field .google.type.TimeOfDay start_time = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Type\TimeOfDay|null + */ + public function getStartTime() + { + return $this->start_time; + } + + public function hasStartTime() + { + return isset($this->start_time); + } + + public function clearStartTime() + { + unset($this->start_time); + } + + /** + * Required. Start time (inclusive). Use 00:00 for the beginning of the day. + * + * Generated from protobuf field .google.type.TimeOfDay start_time = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Type\TimeOfDay $var + * @return $this + */ + public function setStartTime($var) + { + GPBUtil::checkMessage($var, \Google\Type\TimeOfDay::class); + $this->start_time = $var; + + return $this; + } + + /** + * Required. End date. + * + * Generated from protobuf field .google.type.Date end_date = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Type\Date|null + */ + public function getEndDate() + { + return $this->end_date; + } + + public function hasEndDate() + { + return isset($this->end_date); + } + + public function clearEndDate() + { + unset($this->end_date); + } + + /** + * Required. End date. + * + * Generated from protobuf field .google.type.Date end_date = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Type\Date $var + * @return $this + */ + public function setEndDate($var) + { + GPBUtil::checkMessage($var, \Google\Type\Date::class); + $this->end_date = $var; + + return $this; + } + + /** + * Required. End time (exclusive). You may use 24:00 for the end of the day. + * + * Generated from protobuf field .google.type.TimeOfDay end_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Type\TimeOfDay|null + */ + public function getEndTime() + { + return $this->end_time; + } + + public function hasEndTime() + { + return isset($this->end_time); + } + + public function clearEndTime() + { + unset($this->end_time); + } + + /** + * Required. End time (exclusive). You may use 24:00 for the end of the day. + * + * Generated from protobuf field .google.type.TimeOfDay end_time = 4 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Type\TimeOfDay $var + * @return $this + */ + public function setEndTime($var) + { + GPBUtil::checkMessage($var, \Google\Type\TimeOfDay::class); + $this->end_time = $var; + + return $this; + } + +} + diff --git a/Deploy/src/V1/PolicyRule.php b/Deploy/src/V1/PolicyRule.php index eec727aeefe3..24b46dc234e1 100644 --- a/Deploy/src/V1/PolicyRule.php +++ b/Deploy/src/V1/PolicyRule.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\GPBUtil; /** - * Rule to apply. + * Deploy Policy rule. * * Generated from protobuf message google.cloud.deploy.v1.PolicyRule */ @@ -23,7 +23,7 @@ class PolicyRule extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type \Google\Cloud\Deploy\V1\RestrictRollout $restrict_rollouts + * @type \Google\Cloud\Deploy\V1\RolloutRestriction $rollout_restriction * Rollout restrictions. * } */ @@ -35,30 +35,30 @@ public function __construct($data = NULL) { /** * Rollout restrictions. * - * Generated from protobuf field .google.cloud.deploy.v1.RestrictRollout restrict_rollouts = 1; - * @return \Google\Cloud\Deploy\V1\RestrictRollout|null + * Generated from protobuf field .google.cloud.deploy.v1.RolloutRestriction rollout_restriction = 2; + * @return \Google\Cloud\Deploy\V1\RolloutRestriction|null */ - public function getRestrictRollouts() + public function getRolloutRestriction() { - return $this->readOneof(1); + return $this->readOneof(2); } - public function hasRestrictRollouts() + public function hasRolloutRestriction() { - return $this->hasOneof(1); + return $this->hasOneof(2); } /** * Rollout restrictions. * - * Generated from protobuf field .google.cloud.deploy.v1.RestrictRollout restrict_rollouts = 1; - * @param \Google\Cloud\Deploy\V1\RestrictRollout $var + * Generated from protobuf field .google.cloud.deploy.v1.RolloutRestriction rollout_restriction = 2; + * @param \Google\Cloud\Deploy\V1\RolloutRestriction $var * @return $this */ - public function setRestrictRollouts($var) + public function setRolloutRestriction($var) { - GPBUtil::checkMessage($var, \Google\Cloud\Deploy\V1\RestrictRollout::class); - $this->writeOneof(1, $var); + GPBUtil::checkMessage($var, \Google\Cloud\Deploy\V1\RolloutRestriction::class); + $this->writeOneof(2, $var); return $this; } diff --git a/Deploy/src/V1/RetryJobRequest.php b/Deploy/src/V1/RetryJobRequest.php index eb2ecc465174..398162c57ca6 100644 --- a/Deploy/src/V1/RetryJobRequest.php +++ b/Deploy/src/V1/RetryJobRequest.php @@ -34,6 +34,13 @@ class RetryJobRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field string job_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ protected $job_id = ''; + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 4 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $override_deploy_policy; /** * @param string $rollout Required. Name of the Rollout. Format is @@ -67,6 +74,9 @@ public static function build(string $rollout, string $phaseId, string $jobId): s * Required. The phase ID the Job to retry belongs to. * @type string $job_id * Required. The job ID for the Job to retry. + * @type array|\Google\Protobuf\Internal\RepeatedField $override_deploy_policy + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. * } */ public function __construct($data = NULL) { @@ -154,5 +164,33 @@ public function setJobId($var) return $this; } + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 4 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOverrideDeployPolicy() + { + return $this->override_deploy_policy; + } + + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 4 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOverrideDeployPolicy($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->override_deploy_policy = $arr; + + return $this; + } + } diff --git a/Deploy/src/V1/RollbackTargetRequest.php b/Deploy/src/V1/RollbackTargetRequest.php index d4ec8143210e..f7208f661a50 100644 --- a/Deploy/src/V1/RollbackTargetRequest.php +++ b/Deploy/src/V1/RollbackTargetRequest.php @@ -63,6 +63,13 @@ class RollbackTargetRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field bool validate_only = 7 [(.google.api.field_behavior) = OPTIONAL]; */ protected $validate_only = false; + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deploy_policy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 9 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $override_deploy_policy; /** * @param string $name Required. The `DeliveryPipeline` for which the rollback `Rollout` must be @@ -110,6 +117,9 @@ public static function build(string $name, string $targetId, string $rolloutId): * @type bool $validate_only * Optional. If set to true, the request is validated and the user is provided * with a `RollbackTargetResponse`. + * @type array|\Google\Protobuf\Internal\RepeatedField $override_deploy_policy + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deploy_policy}`. * } */ public function __construct($data = NULL) { @@ -321,5 +331,33 @@ public function setValidateOnly($var) return $this; } + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deploy_policy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 9 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOverrideDeployPolicy() + { + return $this->override_deploy_policy; + } + + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deploy_policy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 9 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOverrideDeployPolicy($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->override_deploy_policy = $arr; + + return $this; + } + } diff --git a/Deploy/src/V1/RolloutRestriction.php b/Deploy/src/V1/RolloutRestriction.php new file mode 100644 index 000000000000..77c06e34fd09 --- /dev/null +++ b/Deploy/src/V1/RolloutRestriction.php @@ -0,0 +1,191 @@ +google.cloud.deploy.v1.RolloutRestriction + */ +class RolloutRestriction extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Restriction rule ID. Required and must be unique within a + * DeployPolicy. The format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. + * + * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $id = ''; + /** + * Optional. What invoked the action. If left empty, all invoker types will be + * restricted. + * + * Generated from protobuf field repeated .google.cloud.deploy.v1.DeployPolicy.Invoker invokers = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $invokers; + /** + * Optional. Rollout actions to be restricted as part of the policy. If left + * empty, all actions will be restricted. + * + * Generated from protobuf field repeated .google.cloud.deploy.v1.RolloutRestriction.RolloutActions actions = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $actions; + /** + * Required. Time window within which actions are restricted. + * + * Generated from protobuf field .google.cloud.deploy.v1.TimeWindows time_windows = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $time_windows = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $id + * Required. Restriction rule ID. Required and must be unique within a + * DeployPolicy. The format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. + * @type array|\Google\Protobuf\Internal\RepeatedField $invokers + * Optional. What invoked the action. If left empty, all invoker types will be + * restricted. + * @type array|\Google\Protobuf\Internal\RepeatedField $actions + * Optional. Rollout actions to be restricted as part of the policy. If left + * empty, all actions will be restricted. + * @type \Google\Cloud\Deploy\V1\TimeWindows $time_windows + * Required. Time window within which actions are restricted. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Deploy\V1\CloudDeploy::initOnce(); + parent::__construct($data); + } + + /** + * Required. Restriction rule ID. Required and must be unique within a + * DeployPolicy. The format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. + * + * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Required. Restriction rule ID. Required and must be unique within a + * DeployPolicy. The format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. + * + * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setId($var) + { + GPBUtil::checkString($var, True); + $this->id = $var; + + return $this; + } + + /** + * Optional. What invoked the action. If left empty, all invoker types will be + * restricted. + * + * Generated from protobuf field repeated .google.cloud.deploy.v1.DeployPolicy.Invoker invokers = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getInvokers() + { + return $this->invokers; + } + + /** + * Optional. What invoked the action. If left empty, all invoker types will be + * restricted. + * + * Generated from protobuf field repeated .google.cloud.deploy.v1.DeployPolicy.Invoker invokers = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setInvokers($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Deploy\V1\DeployPolicy\Invoker::class); + $this->invokers = $arr; + + return $this; + } + + /** + * Optional. Rollout actions to be restricted as part of the policy. If left + * empty, all actions will be restricted. + * + * Generated from protobuf field repeated .google.cloud.deploy.v1.RolloutRestriction.RolloutActions actions = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getActions() + { + return $this->actions; + } + + /** + * Optional. Rollout actions to be restricted as part of the policy. If left + * empty, all actions will be restricted. + * + * Generated from protobuf field repeated .google.cloud.deploy.v1.RolloutRestriction.RolloutActions actions = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setActions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Deploy\V1\RolloutRestriction\RolloutActions::class); + $this->actions = $arr; + + return $this; + } + + /** + * Required. Time window within which actions are restricted. + * + * Generated from protobuf field .google.cloud.deploy.v1.TimeWindows time_windows = 4 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Deploy\V1\TimeWindows|null + */ + public function getTimeWindows() + { + return $this->time_windows; + } + + public function hasTimeWindows() + { + return isset($this->time_windows); + } + + public function clearTimeWindows() + { + unset($this->time_windows); + } + + /** + * Required. Time window within which actions are restricted. + * + * Generated from protobuf field .google.cloud.deploy.v1.TimeWindows time_windows = 4 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Deploy\V1\TimeWindows $var + * @return $this + */ + public function setTimeWindows($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Deploy\V1\TimeWindows::class); + $this->time_windows = $var; + + return $this; + } + +} + diff --git a/Deploy/src/V1/RolloutRestriction/RolloutActions.php b/Deploy/src/V1/RolloutRestriction/RolloutActions.php new file mode 100644 index 000000000000..4922462922e9 --- /dev/null +++ b/Deploy/src/V1/RolloutRestriction/RolloutActions.php @@ -0,0 +1,104 @@ +google.cloud.deploy.v1.RolloutRestriction.RolloutActions + */ +class RolloutActions +{ + /** + * Unspecified. + * + * Generated from protobuf enum ROLLOUT_ACTIONS_UNSPECIFIED = 0; + */ + const ROLLOUT_ACTIONS_UNSPECIFIED = 0; + /** + * Advance the rollout to the next phase. + * + * Generated from protobuf enum ADVANCE = 1; + */ + const ADVANCE = 1; + /** + * Approve the rollout. + * + * Generated from protobuf enum APPROVE = 2; + */ + const APPROVE = 2; + /** + * Cancel the rollout. + * + * Generated from protobuf enum CANCEL = 3; + */ + const CANCEL = 3; + /** + * Create a rollout. + * + * Generated from protobuf enum CREATE = 4; + */ + const CREATE = 4; + /** + * Ignore a job result on the rollout. + * + * Generated from protobuf enum IGNORE_JOB = 5; + */ + const IGNORE_JOB = 5; + /** + * Retry a job for a rollout. + * + * Generated from protobuf enum RETRY_JOB = 6; + */ + const RETRY_JOB = 6; + /** + * Rollback a rollout. + * + * Generated from protobuf enum ROLLBACK = 7; + */ + const ROLLBACK = 7; + /** + * Terminate a jobrun. + * + * Generated from protobuf enum TERMINATE_JOBRUN = 8; + */ + const TERMINATE_JOBRUN = 8; + + private static $valueToName = [ + self::ROLLOUT_ACTIONS_UNSPECIFIED => 'ROLLOUT_ACTIONS_UNSPECIFIED', + self::ADVANCE => 'ADVANCE', + self::APPROVE => 'APPROVE', + self::CANCEL => 'CANCEL', + self::CREATE => 'CREATE', + self::IGNORE_JOB => 'IGNORE_JOB', + self::RETRY_JOB => 'RETRY_JOB', + self::ROLLBACK => 'ROLLBACK', + self::TERMINATE_JOBRUN => 'TERMINATE_JOBRUN', + ]; + + 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/Deploy/src/V1/TargetAttribute.php b/Deploy/src/V1/TargetAttribute.php index ac8ea2cd1b8d..21ab6a0e6ce3 100644 --- a/Deploy/src/V1/TargetAttribute.php +++ b/Deploy/src/V1/TargetAttribute.php @@ -9,7 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** - * Contains criteria for selecting Targets. + * Contains criteria for selecting Targets. This could be used to select targets + * for a Deploy Policy or for an Automation. * * Generated from protobuf message google.cloud.deploy.v1.TargetAttribute */ diff --git a/Deploy/src/V1/TerminateJobRunRequest.php b/Deploy/src/V1/TerminateJobRunRequest.php index 4264a7361286..ce381fdbb945 100644 --- a/Deploy/src/V1/TerminateJobRunRequest.php +++ b/Deploy/src/V1/TerminateJobRunRequest.php @@ -22,6 +22,13 @@ class TerminateJobRunRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ protected $name = ''; + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + */ + private $override_deploy_policy; /** * @param string $name Required. Name of the `JobRun`. Format must be @@ -47,6 +54,9 @@ public static function build(string $name): self * @type string $name * Required. Name of the `JobRun`. Format must be * `projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}/jobRuns/{jobRun}`. + * @type array|\Google\Protobuf\Internal\RepeatedField $override_deploy_policy + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. * } */ public function __construct($data = NULL) { @@ -82,5 +92,33 @@ public function setName($var) return $this; } + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOverrideDeployPolicy() + { + return $this->override_deploy_policy; + } + + /** + * Optional. Deploy policies to override. Format is + * `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. + * + * Generated from protobuf field repeated string override_deploy_policy = 2 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOverrideDeployPolicy($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->override_deploy_policy = $arr; + + return $this; + } + } diff --git a/Deploy/src/V1/TimeWindows.php b/Deploy/src/V1/TimeWindows.php new file mode 100644 index 000000000000..ba6e360cdb88 --- /dev/null +++ b/Deploy/src/V1/TimeWindows.php @@ -0,0 +1,141 @@ +google.cloud.deploy.v1.TimeWindows + */ +class TimeWindows extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The time zone in IANA format [IANA Time Zone + * Database](https://www.iana.org/time-zones) (e.g. America/New_York). + * + * Generated from protobuf field string time_zone = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $time_zone = ''; + /** + * Optional. One-time windows within which actions are restricted. + * + * Generated from protobuf field repeated .google.cloud.deploy.v1.OneTimeWindow one_time_windows = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $one_time_windows; + /** + * Optional. Recurring weekly windows within which actions are restricted. + * + * Generated from protobuf field repeated .google.cloud.deploy.v1.WeeklyWindow weekly_windows = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $weekly_windows; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $time_zone + * Required. The time zone in IANA format [IANA Time Zone + * Database](https://www.iana.org/time-zones) (e.g. America/New_York). + * @type array<\Google\Cloud\Deploy\V1\OneTimeWindow>|\Google\Protobuf\Internal\RepeatedField $one_time_windows + * Optional. One-time windows within which actions are restricted. + * @type array<\Google\Cloud\Deploy\V1\WeeklyWindow>|\Google\Protobuf\Internal\RepeatedField $weekly_windows + * Optional. Recurring weekly windows within which actions are restricted. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Deploy\V1\CloudDeploy::initOnce(); + parent::__construct($data); + } + + /** + * Required. The time zone in IANA format [IANA Time Zone + * Database](https://www.iana.org/time-zones) (e.g. America/New_York). + * + * Generated from protobuf field string time_zone = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getTimeZone() + { + return $this->time_zone; + } + + /** + * Required. The time zone in IANA format [IANA Time Zone + * Database](https://www.iana.org/time-zones) (e.g. America/New_York). + * + * Generated from protobuf field string time_zone = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setTimeZone($var) + { + GPBUtil::checkString($var, True); + $this->time_zone = $var; + + return $this; + } + + /** + * Optional. One-time windows within which actions are restricted. + * + * Generated from protobuf field repeated .google.cloud.deploy.v1.OneTimeWindow one_time_windows = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getOneTimeWindows() + { + return $this->one_time_windows; + } + + /** + * Optional. One-time windows within which actions are restricted. + * + * Generated from protobuf field repeated .google.cloud.deploy.v1.OneTimeWindow one_time_windows = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param array<\Google\Cloud\Deploy\V1\OneTimeWindow>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setOneTimeWindows($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Deploy\V1\OneTimeWindow::class); + $this->one_time_windows = $arr; + + return $this; + } + + /** + * Optional. Recurring weekly windows within which actions are restricted. + * + * Generated from protobuf field repeated .google.cloud.deploy.v1.WeeklyWindow weekly_windows = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getWeeklyWindows() + { + return $this->weekly_windows; + } + + /** + * Optional. Recurring weekly windows within which actions are restricted. + * + * Generated from protobuf field repeated .google.cloud.deploy.v1.WeeklyWindow weekly_windows = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param array<\Google\Cloud\Deploy\V1\WeeklyWindow>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setWeeklyWindows($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Deploy\V1\WeeklyWindow::class); + $this->weekly_windows = $arr; + + return $this; + } + +} + diff --git a/Deploy/src/V1/Type.php b/Deploy/src/V1/Type.php index 1835a51f34aa..613d3aa26e49 100644 --- a/Deploy/src/V1/Type.php +++ b/Deploy/src/V1/Type.php @@ -55,6 +55,12 @@ class Type * Generated from protobuf enum TYPE_ROLLOUT_UPDATE = 7; */ const TYPE_ROLLOUT_UPDATE = 7; + /** + * Deploy Policy evaluation. + * + * Generated from protobuf enum TYPE_DEPLOY_POLICY_EVALUATION = 8; + */ + const TYPE_DEPLOY_POLICY_EVALUATION = 8; /** * Deprecated: This field is never used. Use release_render log type instead. * @@ -70,6 +76,7 @@ class Type self::TYPE_RESTRICTION_VIOLATED => 'TYPE_RESTRICTION_VIOLATED', self::TYPE_RESOURCE_DELETED => 'TYPE_RESOURCE_DELETED', self::TYPE_ROLLOUT_UPDATE => 'TYPE_ROLLOUT_UPDATE', + self::TYPE_DEPLOY_POLICY_EVALUATION => 'TYPE_DEPLOY_POLICY_EVALUATION', self::TYPE_RENDER_STATUES_CHANGE => 'TYPE_RENDER_STATUES_CHANGE', ]; diff --git a/Deploy/src/V1/WeeklyWindow.php b/Deploy/src/V1/WeeklyWindow.php new file mode 100644 index 000000000000..a0212780dd12 --- /dev/null +++ b/Deploy/src/V1/WeeklyWindow.php @@ -0,0 +1,176 @@ +google.cloud.deploy.v1.WeeklyWindow + */ +class WeeklyWindow extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Days of week. If left empty, all days of the week will be + * included. + * + * Generated from protobuf field repeated .google.type.DayOfWeek days_of_week = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $days_of_week; + /** + * Optional. Start time (inclusive). Use 00:00 for the beginning of the day. + * If you specify start_time you must also specify end_time. If left empty, + * this will block for the entire day for the days specified in days_of_week. + * + * Generated from protobuf field .google.type.TimeOfDay start_time = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $start_time = null; + /** + * Optional. End time (exclusive). Use 24:00 to indicate midnight. If you + * specify end_time you must also specify start_time. If left empty, this will + * block for the entire day for the days specified in days_of_week. + * + * Generated from protobuf field .google.type.TimeOfDay end_time = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $end_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $days_of_week + * Optional. Days of week. If left empty, all days of the week will be + * included. + * @type \Google\Type\TimeOfDay $start_time + * Optional. Start time (inclusive). Use 00:00 for the beginning of the day. + * If you specify start_time you must also specify end_time. If left empty, + * this will block for the entire day for the days specified in days_of_week. + * @type \Google\Type\TimeOfDay $end_time + * Optional. End time (exclusive). Use 24:00 to indicate midnight. If you + * specify end_time you must also specify start_time. If left empty, this will + * block for the entire day for the days specified in days_of_week. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Deploy\V1\CloudDeploy::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Days of week. If left empty, all days of the week will be + * included. + * + * Generated from protobuf field repeated .google.type.DayOfWeek days_of_week = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDaysOfWeek() + { + return $this->days_of_week; + } + + /** + * Optional. Days of week. If left empty, all days of the week will be + * included. + * + * Generated from protobuf field repeated .google.type.DayOfWeek days_of_week = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDaysOfWeek($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Type\DayOfWeek::class); + $this->days_of_week = $arr; + + return $this; + } + + /** + * Optional. Start time (inclusive). Use 00:00 for the beginning of the day. + * If you specify start_time you must also specify end_time. If left empty, + * this will block for the entire day for the days specified in days_of_week. + * + * Generated from protobuf field .google.type.TimeOfDay start_time = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Type\TimeOfDay|null + */ + public function getStartTime() + { + return $this->start_time; + } + + public function hasStartTime() + { + return isset($this->start_time); + } + + public function clearStartTime() + { + unset($this->start_time); + } + + /** + * Optional. Start time (inclusive). Use 00:00 for the beginning of the day. + * If you specify start_time you must also specify end_time. If left empty, + * this will block for the entire day for the days specified in days_of_week. + * + * Generated from protobuf field .google.type.TimeOfDay start_time = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Type\TimeOfDay $var + * @return $this + */ + public function setStartTime($var) + { + GPBUtil::checkMessage($var, \Google\Type\TimeOfDay::class); + $this->start_time = $var; + + return $this; + } + + /** + * Optional. End time (exclusive). Use 24:00 to indicate midnight. If you + * specify end_time you must also specify start_time. If left empty, this will + * block for the entire day for the days specified in days_of_week. + * + * Generated from protobuf field .google.type.TimeOfDay end_time = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Type\TimeOfDay|null + */ + public function getEndTime() + { + return $this->end_time; + } + + public function hasEndTime() + { + return isset($this->end_time); + } + + public function clearEndTime() + { + unset($this->end_time); + } + + /** + * Optional. End time (exclusive). Use 24:00 to indicate midnight. If you + * specify end_time you must also specify start_time. If left empty, this will + * block for the entire day for the days specified in days_of_week. + * + * Generated from protobuf field .google.type.TimeOfDay end_time = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Type\TimeOfDay $var + * @return $this + */ + public function setEndTime($var) + { + GPBUtil::checkMessage($var, \Google\Type\TimeOfDay::class); + $this->end_time = $var; + + return $this; + } + +} + diff --git a/Deploy/src/V1/gapic_metadata.json b/Deploy/src/V1/gapic_metadata.json index 4fb04e21a05b..cc25967ba57d 100644 --- a/Deploy/src/V1/gapic_metadata.json +++ b/Deploy/src/V1/gapic_metadata.json @@ -50,6 +50,11 @@ "createDeliveryPipeline" ] }, + "CreateDeployPolicy": { + "methods": [ + "createDeployPolicy" + ] + }, "CreateRelease": { "methods": [ "createRelease" @@ -80,6 +85,11 @@ "deleteDeliveryPipeline" ] }, + "DeleteDeployPolicy": { + "methods": [ + "deleteDeployPolicy" + ] + }, "DeleteTarget": { "methods": [ "deleteTarget" @@ -110,6 +120,11 @@ "getDeliveryPipeline" ] }, + "GetDeployPolicy": { + "methods": [ + "getDeployPolicy" + ] + }, "GetJobRun": { "methods": [ "getJobRun" @@ -155,6 +170,11 @@ "listDeliveryPipelines" ] }, + "ListDeployPolicies": { + "methods": [ + "listDeployPolicies" + ] + }, "ListJobRuns": { "methods": [ "listJobRuns" @@ -205,6 +225,11 @@ "updateDeliveryPipeline" ] }, + "UpdateDeployPolicy": { + "methods": [ + "updateDeployPolicy" + ] + }, "UpdateTarget": { "methods": [ "updateTarget" diff --git a/Deploy/src/V1/resources/cloud_deploy_client_config.json b/Deploy/src/V1/resources/cloud_deploy_client_config.json index 344ed8b2d90a..89a03316253f 100644 --- a/Deploy/src/V1/resources/cloud_deploy_client_config.json +++ b/Deploy/src/V1/resources/cloud_deploy_client_config.json @@ -78,6 +78,11 @@ "retry_codes_name": "no_retry_1_codes", "retry_params_name": "no_retry_1_params" }, + "CreateDeployPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, "CreateRelease": { "timeout_millis": 60000, "retry_codes_name": "no_retry_1_codes", @@ -108,6 +113,11 @@ "retry_codes_name": "no_retry_1_codes", "retry_params_name": "no_retry_1_params" }, + "DeleteDeployPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, "DeleteTarget": { "timeout_millis": 60000, "retry_codes_name": "no_retry_1_codes", @@ -138,6 +148,11 @@ "retry_codes_name": "retry_policy_1_codes", "retry_params_name": "retry_policy_1_params" }, + "GetDeployPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, "GetJobRun": { "timeout_millis": 60000, "retry_codes_name": "retry_policy_1_codes", @@ -183,6 +198,11 @@ "retry_codes_name": "retry_policy_1_codes", "retry_params_name": "retry_policy_1_params" }, + "ListDeployPolicies": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, "ListJobRuns": { "timeout_millis": 60000, "retry_codes_name": "retry_policy_1_codes", @@ -233,6 +253,11 @@ "retry_codes_name": "no_retry_1_codes", "retry_params_name": "no_retry_1_params" }, + "UpdateDeployPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_1_codes", + "retry_params_name": "no_retry_1_params" + }, "UpdateTarget": { "timeout_millis": 60000, "retry_codes_name": "no_retry_1_codes", diff --git a/Deploy/src/V1/resources/cloud_deploy_descriptor_config.php b/Deploy/src/V1/resources/cloud_deploy_descriptor_config.php index 1b7b7bbc3ac4..9842887d33c3 100644 --- a/Deploy/src/V1/resources/cloud_deploy_descriptor_config.php +++ b/Deploy/src/V1/resources/cloud_deploy_descriptor_config.php @@ -80,6 +80,25 @@ ], ], ], + 'CreateDeployPolicy' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Deploy\V1\DeployPolicy', + 'metadataReturnType' => '\Google\Cloud\Deploy\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'CreateRelease' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Deploy\V1\Release', @@ -194,6 +213,25 @@ ], ], ], + 'DeleteDeployPolicy' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\Deploy\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'DeleteTarget' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Protobuf\GPBEmpty', @@ -273,6 +311,26 @@ ], ], ], + 'UpdateDeployPolicy' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Deploy\V1\DeployPolicy', + 'metadataReturnType' => '\Google\Cloud\Deploy\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'deploy_policy.name', + 'fieldAccessors' => [ + 'getDeployPolicy', + 'getName', + ], + ], + ], + ], 'UpdateTarget' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Deploy\V1\Target', @@ -413,6 +471,18 @@ ], ], ], + 'GetDeployPolicy' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Deploy\V1\DeployPolicy', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'GetJobRun' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\Deploy\V1\JobRun', @@ -553,6 +623,26 @@ ], ], ], + 'ListDeployPolicies' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getDeployPolicies', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Deploy\V1\ListDeployPoliciesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'ListJobRuns' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -750,6 +840,7 @@ 'config' => 'projects/{project}/locations/{location}/config', 'customTargetType' => 'projects/{project}/locations/{location}/customTargetTypes/{custom_target_type}', 'deliveryPipeline' => 'projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}', + 'deployPolicy' => 'projects/{project}/locations/{location}/deployPolicies/{deploy_policy}', 'job' => 'projects/{project}/locations/{location}/jobs/{job}', 'jobRun' => 'projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}/releases/{release}/rollouts/{rollout}/jobRuns/{job_run}', 'location' => 'projects/{project}/locations/{location}', diff --git a/Deploy/src/V1/resources/cloud_deploy_rest_client_config.php b/Deploy/src/V1/resources/cloud_deploy_rest_client_config.php index febaff6b324f..0391c32a6344 100644 --- a/Deploy/src/V1/resources/cloud_deploy_rest_client_config.php +++ b/Deploy/src/V1/resources/cloud_deploy_rest_client_config.php @@ -128,6 +128,21 @@ 'delivery_pipeline_id', ], ], + 'CreateDeployPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/deployPolicies', + 'body' => 'deploy_policy', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + 'queryParams' => [ + 'deploy_policy_id', + ], + ], 'CreateRelease' => [ 'method' => 'post', 'uriTemplate' => '/v1/{parent=projects/*/locations/*/deliveryPipelines/*}/releases', @@ -206,6 +221,17 @@ ], ], ], + 'DeleteDeployPolicy' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/deployPolicies/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'DeleteTarget' => [ 'method' => 'delete', 'uriTemplate' => '/v1/{name=projects/*/locations/*/targets/*}', @@ -272,6 +298,17 @@ ], ], ], + 'GetDeployPolicy' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/deployPolicies/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'GetJobRun' => [ 'method' => 'get', 'uriTemplate' => '/v1/{name=projects/*/locations/*/deliveryPipelines/*/releases/*/rollouts/*/jobRuns/*}', @@ -372,6 +409,17 @@ ], ], ], + 'ListDeployPolicies' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/deployPolicies', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], 'ListJobRuns' => [ 'method' => 'get', 'uriTemplate' => '/v1/{parent=projects/*/locations/*/deliveryPipelines/*/releases/*/rollouts/*}/jobRuns', @@ -500,6 +548,22 @@ 'update_mask', ], ], + 'UpdateDeployPolicy' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{deploy_policy.name=projects/*/locations/*/deployPolicies/*}', + 'body' => 'deploy_policy', + 'placeholders' => [ + 'deploy_policy.name' => [ + 'getters' => [ + 'getDeployPolicy', + 'getName', + ], + ], + ], + 'queryParams' => [ + 'update_mask', + ], + ], 'UpdateTarget' => [ 'method' => 'patch', 'uriTemplate' => '/v1/{target.name=projects/*/locations/*/targets/*}', diff --git a/Deploy/tests/Unit/V1/Client/CloudDeployClientTest.php b/Deploy/tests/Unit/V1/Client/CloudDeployClientTest.php index f0572c7f722d..afb8c134eed8 100644 --- a/Deploy/tests/Unit/V1/Client/CloudDeployClientTest.php +++ b/Deploy/tests/Unit/V1/Client/CloudDeployClientTest.php @@ -44,6 +44,7 @@ use Google\Cloud\Deploy\V1\CreateAutomationRequest; use Google\Cloud\Deploy\V1\CreateCustomTargetTypeRequest; use Google\Cloud\Deploy\V1\CreateDeliveryPipelineRequest; +use Google\Cloud\Deploy\V1\CreateDeployPolicyRequest; use Google\Cloud\Deploy\V1\CreateReleaseRequest; use Google\Cloud\Deploy\V1\CreateRolloutRequest; use Google\Cloud\Deploy\V1\CreateTargetRequest; @@ -51,13 +52,16 @@ use Google\Cloud\Deploy\V1\DeleteAutomationRequest; use Google\Cloud\Deploy\V1\DeleteCustomTargetTypeRequest; use Google\Cloud\Deploy\V1\DeleteDeliveryPipelineRequest; +use Google\Cloud\Deploy\V1\DeleteDeployPolicyRequest; use Google\Cloud\Deploy\V1\DeleteTargetRequest; use Google\Cloud\Deploy\V1\DeliveryPipeline; +use Google\Cloud\Deploy\V1\DeployPolicy; use Google\Cloud\Deploy\V1\GetAutomationRequest; use Google\Cloud\Deploy\V1\GetAutomationRunRequest; use Google\Cloud\Deploy\V1\GetConfigRequest; use Google\Cloud\Deploy\V1\GetCustomTargetTypeRequest; use Google\Cloud\Deploy\V1\GetDeliveryPipelineRequest; +use Google\Cloud\Deploy\V1\GetDeployPolicyRequest; use Google\Cloud\Deploy\V1\GetJobRunRequest; use Google\Cloud\Deploy\V1\GetReleaseRequest; use Google\Cloud\Deploy\V1\GetRolloutRequest; @@ -73,6 +77,8 @@ use Google\Cloud\Deploy\V1\ListCustomTargetTypesResponse; use Google\Cloud\Deploy\V1\ListDeliveryPipelinesRequest; use Google\Cloud\Deploy\V1\ListDeliveryPipelinesResponse; +use Google\Cloud\Deploy\V1\ListDeployPoliciesRequest; +use Google\Cloud\Deploy\V1\ListDeployPoliciesResponse; use Google\Cloud\Deploy\V1\ListJobRunsRequest; use Google\Cloud\Deploy\V1\ListJobRunsResponse; use Google\Cloud\Deploy\V1\ListReleasesRequest; @@ -93,6 +99,7 @@ use Google\Cloud\Deploy\V1\UpdateAutomationRequest; use Google\Cloud\Deploy\V1\UpdateCustomTargetTypeRequest; use Google\Cloud\Deploy\V1\UpdateDeliveryPipelineRequest; +use Google\Cloud\Deploy\V1\UpdateDeployPolicyRequest; use Google\Cloud\Deploy\V1\UpdateTargetRequest; use Google\Cloud\Iam\V1\GetIamPolicyRequest; use Google\Cloud\Iam\V1\Policy; @@ -963,6 +970,160 @@ public function createDeliveryPipelineExceptionTest() $this->assertTrue($operationsTransport->isExhausted()); } + /** @test */ + public function createDeployPolicyTest() + { + $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/createDeployPolicyTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $uid = 'uid115792'; + $description = 'description-1724546052'; + $suspended = false; + $etag = 'etag3123477'; + $expectedResponse = new DeployPolicy(); + $expectedResponse->setName($name); + $expectedResponse->setUid($uid); + $expectedResponse->setDescription($description); + $expectedResponse->setSuspended($suspended); + $expectedResponse->setEtag($etag); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createDeployPolicyTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $deployPolicyId = 'deployPolicyId1355226608'; + $deployPolicy = new DeployPolicy(); + $deployPolicySelectors = []; + $deployPolicy->setSelectors($deployPolicySelectors); + $deployPolicyRules = []; + $deployPolicy->setRules($deployPolicyRules); + $request = (new CreateDeployPolicyRequest()) + ->setParent($formattedParent) + ->setDeployPolicyId($deployPolicyId) + ->setDeployPolicy($deployPolicy); + $response = $gapicClient->createDeployPolicy($request); + $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.cloud.deploy.v1.CloudDeploy/CreateDeployPolicy', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getDeployPolicyId(); + $this->assertProtobufEquals($deployPolicyId, $actualValue); + $actualValue = $actualApiRequestObject->getDeployPolicy(); + $this->assertProtobufEquals($deployPolicy, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createDeployPolicyTest'); + $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 createDeployPolicyExceptionTest() + { + $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/createDeployPolicyTest'); + $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]'); + $deployPolicyId = 'deployPolicyId1355226608'; + $deployPolicy = new DeployPolicy(); + $deployPolicySelectors = []; + $deployPolicy->setSelectors($deployPolicySelectors); + $deployPolicyRules = []; + $deployPolicy->setRules($deployPolicyRules); + $request = (new CreateDeployPolicyRequest()) + ->setParent($formattedParent) + ->setDeployPolicyId($deployPolicyId) + ->setDeployPolicy($deployPolicy); + $response = $gapicClient->createDeployPolicy($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createDeployPolicyTest'); + 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 createReleaseTest() { @@ -1787,6 +1948,128 @@ public function deleteDeliveryPipelineExceptionTest() $this->assertTrue($operationsTransport->isExhausted()); } + /** @test */ + public function deleteDeployPolicyTest() + { + $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/deleteDeployPolicyTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/deleteDeployPolicyTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $gapicClient->deployPolicyName('[PROJECT]', '[LOCATION]', '[DEPLOY_POLICY]'); + $request = (new DeleteDeployPolicyRequest())->setName($formattedName); + $response = $gapicClient->deleteDeployPolicy($request); + $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.cloud.deploy.v1.CloudDeploy/DeleteDeployPolicy', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteDeployPolicyTest'); + $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 deleteDeployPolicyExceptionTest() + { + $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/deleteDeployPolicyTest'); + $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->deployPolicyName('[PROJECT]', '[LOCATION]', '[DEPLOY_POLICY]'); + $request = (new DeleteDeployPolicyRequest())->setName($formattedName); + $response = $gapicClient->deleteDeployPolicy($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteDeployPolicyTest'); + 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 deleteTargetTest() { @@ -2284,6 +2567,79 @@ public function getDeliveryPipelineExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function getDeployPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $uid = 'uid115792'; + $description = 'description-1724546052'; + $suspended = false; + $etag = 'etag3123477'; + $expectedResponse = new DeployPolicy(); + $expectedResponse->setName($name2); + $expectedResponse->setUid($uid); + $expectedResponse->setDescription($description); + $expectedResponse->setSuspended($suspended); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->deployPolicyName('[PROJECT]', '[LOCATION]', '[DEPLOY_POLICY]'); + $request = (new GetDeployPolicyRequest())->setName($formattedName); + $response = $gapicClient->getDeployPolicy($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.deploy.v1.CloudDeploy/GetDeployPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getDeployPolicyExceptionTest() + { + $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->deployPolicyName('[PROJECT]', '[LOCATION]', '[DEPLOY_POLICY]'); + $request = (new GetDeployPolicyRequest())->setName($formattedName); + try { + $gapicClient->getDeployPolicy($request); + // 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 getJobRunTest() { @@ -2991,6 +3347,77 @@ public function listDeliveryPipelinesExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function listDeployPoliciesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $deployPoliciesElement = new DeployPolicy(); + $deployPolicies = [$deployPoliciesElement]; + $expectedResponse = new ListDeployPoliciesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setDeployPolicies($deployPolicies); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $request = (new ListDeployPoliciesRequest())->setParent($formattedParent); + $response = $gapicClient->listDeployPolicies($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getDeployPolicies()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.deploy.v1.CloudDeploy/ListDeployPolicies', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listDeployPoliciesExceptionTest() + { + $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]'); + $request = (new ListDeployPoliciesRequest())->setParent($formattedParent); + try { + $gapicClient->listDeployPolicies($request); + // 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 listJobRunsTest() { @@ -3960,6 +4387,150 @@ public function updateDeliveryPipelineExceptionTest() $this->assertTrue($operationsTransport->isExhausted()); } + /** @test */ + public function updateDeployPolicyTest() + { + $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/updateDeployPolicyTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $uid = 'uid115792'; + $description = 'description-1724546052'; + $suspended = false; + $etag = 'etag3123477'; + $expectedResponse = new DeployPolicy(); + $expectedResponse->setName($name); + $expectedResponse->setUid($uid); + $expectedResponse->setDescription($description); + $expectedResponse->setSuspended($suspended); + $expectedResponse->setEtag($etag); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateDeployPolicyTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $updateMask = new FieldMask(); + $deployPolicy = new DeployPolicy(); + $deployPolicySelectors = []; + $deployPolicy->setSelectors($deployPolicySelectors); + $deployPolicyRules = []; + $deployPolicy->setRules($deployPolicyRules); + $request = (new UpdateDeployPolicyRequest())->setUpdateMask($updateMask)->setDeployPolicy($deployPolicy); + $response = $gapicClient->updateDeployPolicy($request); + $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.cloud.deploy.v1.CloudDeploy/UpdateDeployPolicy', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getUpdateMask(); + $this->assertProtobufEquals($updateMask, $actualValue); + $actualValue = $actualApiRequestObject->getDeployPolicy(); + $this->assertProtobufEquals($deployPolicy, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateDeployPolicyTest'); + $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 updateDeployPolicyExceptionTest() + { + $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/updateDeployPolicyTest'); + $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 + $updateMask = new FieldMask(); + $deployPolicy = new DeployPolicy(); + $deployPolicySelectors = []; + $deployPolicy->setSelectors($deployPolicySelectors); + $deployPolicyRules = []; + $deployPolicy->setRules($deployPolicyRules); + $request = (new UpdateDeployPolicyRequest())->setUpdateMask($updateMask)->setDeployPolicy($deployPolicy); + $response = $gapicClient->updateDeployPolicy($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateDeployPolicyTest'); + 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 updateTargetTest() {