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: [CertificateManager] Added Trust Configs and DnsAuthorization.Type to Certificate Manager #7160

Merged
merged 2 commits into from
Mar 22, 2024
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 CertificateManager/metadata/V1/CertificateManager.php
Binary file not shown.
Binary file added CertificateManager/metadata/V1/TrustConfig.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/*
* Copyright 2024 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 certificatemanager_v1_generated_CertificateManager_CreateTrustConfig_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\CertificateManager\V1\Client\CertificateManagerClient;
use Google\Cloud\CertificateManager\V1\CreateTrustConfigRequest;
use Google\Cloud\CertificateManager\V1\TrustConfig;
use Google\Rpc\Status;

/**
* Creates a new TrustConfig in a given project and location.
*
* @param string $formattedParent The parent resource of the TrustConfig. Must be in the format
* `projects/&#42;/locations/*`. Please see
* {@see CertificateManagerClient::locationName()} for help formatting this field.
* @param string $trustConfigId A user-provided name of the TrustConfig. Must match the regexp
* `[a-z0-9-]{1,63}`.
*/
function create_trust_config_sample(string $formattedParent, string $trustConfigId): void
{
// Create a client.
$certificateManagerClient = new CertificateManagerClient();

// Prepare the request message.
$trustConfig = new TrustConfig();
$request = (new CreateTrustConfigRequest())
->setParent($formattedParent)
->setTrustConfigId($trustConfigId)
->setTrustConfig($trustConfig);

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

if ($response->operationSucceeded()) {
/** @var TrustConfig $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 = CertificateManagerClient::locationName('[PROJECT]', '[LOCATION]');
$trustConfigId = '[TRUST_CONFIG_ID]';

create_trust_config_sample($formattedParent, $trustConfigId);
}
// [END certificatemanager_v1_generated_CertificateManager_CreateTrustConfig_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/*
* Copyright 2024 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 certificatemanager_v1_generated_CertificateManager_DeleteTrustConfig_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\CertificateManager\V1\Client\CertificateManagerClient;
use Google\Cloud\CertificateManager\V1\DeleteTrustConfigRequest;
use Google\Rpc\Status;

/**
* Deletes a single TrustConfig.
*
* @param string $formattedName A name of the TrustConfig to delete. Must be in the format
* `projects/&#42;/locations/&#42;/trustConfigs/*`. Please see
* {@see CertificateManagerClient::trustConfigName()} for help formatting this field.
*/
function delete_trust_config_sample(string $formattedName): void
{
// Create a client.
$certificateManagerClient = new CertificateManagerClient();

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

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $certificateManagerClient->deleteTrustConfig($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 = CertificateManagerClient::trustConfigName(
'[PROJECT]',
'[LOCATION]',
'[TRUST_CONFIG]'
);

delete_trust_config_sample($formattedName);
}
// [END certificatemanager_v1_generated_CertificateManager_DeleteTrustConfig_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/*
* Copyright 2024 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 certificatemanager_v1_generated_CertificateManager_GetTrustConfig_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\CertificateManager\V1\Client\CertificateManagerClient;
use Google\Cloud\CertificateManager\V1\GetTrustConfigRequest;
use Google\Cloud\CertificateManager\V1\TrustConfig;

/**
* Gets details of a single TrustConfig.
*
* @param string $formattedName A name of the TrustConfig to describe. Must be in the format
* `projects/&#42;/locations/&#42;/trustConfigs/*`. Please see
* {@see CertificateManagerClient::trustConfigName()} for help formatting this field.
*/
function get_trust_config_sample(string $formattedName): void
{
// Create a client.
$certificateManagerClient = new CertificateManagerClient();

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

// Call the API and handle any network failures.
try {
/** @var TrustConfig $response */
$response = $certificateManagerClient->getTrustConfig($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 = CertificateManagerClient::trustConfigName(
'[PROJECT]',
'[LOCATION]',
'[TRUST_CONFIG]'
);

get_trust_config_sample($formattedName);
}
// [END certificatemanager_v1_generated_CertificateManager_GetTrustConfig_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2024 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 certificatemanager_v1_generated_CertificateManager_ListTrustConfigs_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\CertificateManager\V1\Client\CertificateManagerClient;
use Google\Cloud\CertificateManager\V1\ListTrustConfigsRequest;
use Google\Cloud\CertificateManager\V1\TrustConfig;

/**
* Lists TrustConfigs in a given project and location.
*
* @param string $formattedParent The project and location from which the TrustConfigs should be
* listed, specified in the format `projects/&#42;/locations/*`. Please see
* {@see CertificateManagerClient::locationName()} for help formatting this field.
*/
function list_trust_configs_sample(string $formattedParent): void
{
// Create a client.
$certificateManagerClient = new CertificateManagerClient();

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

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

/** @var TrustConfig $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 = CertificateManagerClient::locationName('[PROJECT]', '[LOCATION]');

list_trust_configs_sample($formattedParent);
}
// [END certificatemanager_v1_generated_CertificateManager_ListTrustConfigs_sync]
Loading
Loading