Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [Deploy] Add custom target type support #6841

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Deploy/metadata/V1/CloudDeploy.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START clouddeploy_v1_generated_CloudDeploy_CreateCustomTargetType_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Deploy\V1\Client\CloudDeployClient;
use Google\Cloud\Deploy\V1\CreateCustomTargetTypeRequest;
use Google\Cloud\Deploy\V1\CustomTargetType;
use Google\Rpc\Status;

/**
* Creates a new CustomTargetType in a given project and location.
*
* @param string $formattedParent The parent collection in which the `CustomTargetType` should be
* created in. Format should be
* `projects/{project_id}/locations/{location_name}`. Please see
* {@see CloudDeployClient::locationName()} for help formatting this field.
* @param string $customTargetTypeId ID of the `CustomTargetType`.
*/
function create_custom_target_type_sample(
string $formattedParent,
string $customTargetTypeId
): void {
// Create a client.
$cloudDeployClient = new CloudDeployClient();

// Prepare the request message.
$customTargetType = new CustomTargetType();
$request = (new CreateCustomTargetTypeRequest())
->setParent($formattedParent)
->setCustomTargetTypeId($customTargetTypeId)
->setCustomTargetType($customTargetType);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $cloudDeployClient->createCustomTargetType($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var CustomTargetType $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = CloudDeployClient::locationName('[PROJECT]', '[LOCATION]');
$customTargetTypeId = '[CUSTOM_TARGET_TYPE_ID]';

create_custom_target_type_sample($formattedParent, $customTargetTypeId);
}
// [END clouddeploy_v1_generated_CloudDeploy_CreateCustomTargetType_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START clouddeploy_v1_generated_CloudDeploy_DeleteCustomTargetType_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Deploy\V1\Client\CloudDeployClient;
use Google\Cloud\Deploy\V1\DeleteCustomTargetTypeRequest;
use Google\Rpc\Status;

/**
* Deletes a single CustomTargetType.
*
* @param string $formattedName The name of the `CustomTargetType` to delete. Format must be
* `projects/{project_id}/locations/{location_name}/customTargetTypes/{custom_target_type}`. Please see
* {@see CloudDeployClient::customTargetTypeName()} for help formatting this field.
*/
function delete_custom_target_type_sample(string $formattedName): void
{
// Create a client.
$cloudDeployClient = new CloudDeployClient();

// Prepare the request message.
$request = (new DeleteCustomTargetTypeRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $cloudDeployClient->deleteCustomTargetType($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
printf('Operation completed successfully.' . PHP_EOL);
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = CloudDeployClient::customTargetTypeName(
'[PROJECT]',
'[LOCATION]',
'[CUSTOM_TARGET_TYPE]'
);

delete_custom_target_type_sample($formattedName);
}
// [END clouddeploy_v1_generated_CloudDeploy_DeleteCustomTargetType_sync]
76 changes: 76 additions & 0 deletions Deploy/samples/V1/CloudDeployClient/get_custom_target_type.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START clouddeploy_v1_generated_CloudDeploy_GetCustomTargetType_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Deploy\V1\Client\CloudDeployClient;
use Google\Cloud\Deploy\V1\CustomTargetType;
use Google\Cloud\Deploy\V1\GetCustomTargetTypeRequest;

/**
* Gets details of a single CustomTargetType.
*
* @param string $formattedName Name of the `CustomTargetType`. Format must be
* `projects/{project_id}/locations/{location_name}/customTargetTypes/{custom_target_type}`. Please see
* {@see CloudDeployClient::customTargetTypeName()} for help formatting this field.
*/
function get_custom_target_type_sample(string $formattedName): void
{
// Create a client.
$cloudDeployClient = new CloudDeployClient();

// Prepare the request message.
$request = (new GetCustomTargetTypeRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var CustomTargetType $response */
$response = $cloudDeployClient->getCustomTargetType($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = CloudDeployClient::customTargetTypeName(
'[PROJECT]',
'[LOCATION]',
'[CUSTOM_TARGET_TYPE]'
);

get_custom_target_type_sample($formattedName);
}
// [END clouddeploy_v1_generated_CloudDeploy_GetCustomTargetType_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
/**
* Lists AutomationRuns in a given project and location.
*
* @param string $formattedParent The parent, which owns this collection of automationRuns. Format
* must be
* @param string $formattedParent The parent `Delivery Pipeline`, which owns this collection of
* automationRuns. Format must be
* `projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}`. Please see
* {@see CloudDeployClient::deliveryPipelineName()} for help formatting this field.
*/
Expand Down
4 changes: 2 additions & 2 deletions Deploy/samples/V1/CloudDeployClient/list_automations.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
/**
* Lists Automations in a given project and location.
*
* @param string $formattedParent The parent, which owns this collection of automations. Format
* must be
* @param string $formattedParent The parent `Delivery Pipeline`, which owns this collection of
* automations. Format must be
* `projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}`. Please see
* {@see CloudDeployClient::deliveryPipelineName()} for help formatting this field.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START clouddeploy_v1_generated_CloudDeploy_ListCustomTargetTypes_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Deploy\V1\Client\CloudDeployClient;
use Google\Cloud\Deploy\V1\CustomTargetType;
use Google\Cloud\Deploy\V1\ListCustomTargetTypesRequest;

/**
* Lists CustomTargetTypes in a given project and location.
*
* @param string $formattedParent The parent that owns this collection of custom target types.
* Format must be `projects/{project_id}/locations/{location_name}`. Please see
* {@see CloudDeployClient::locationName()} for help formatting this field.
*/
function list_custom_target_types_sample(string $formattedParent): void
{
// Create a client.
$cloudDeployClient = new CloudDeployClient();

// Prepare the request message.
$request = (new ListCustomTargetTypesRequest())
->setParent($formattedParent);

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $cloudDeployClient->listCustomTargetTypes($request);

/** @var CustomTargetType $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = CloudDeployClient::locationName('[PROJECT]', '[LOCATION]');

list_custom_target_types_sample($formattedParent);
}
// [END clouddeploy_v1_generated_CloudDeploy_ListCustomTargetTypes_sync]
Loading