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

chore: [AssuredWorkloads] promote v1beta1 to use the new surface for stable (v1) release #7453

Merged
merged 2 commits into from
Jun 21, 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
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

// [START assuredworkloads_v1beta1_generated_AssuredWorkloadsService_AnalyzeWorkloadMove_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AssuredWorkloads\V1beta1\AnalyzeWorkloadMoveRequest;
use Google\Cloud\AssuredWorkloads\V1beta1\AnalyzeWorkloadMoveResponse;
use Google\Cloud\AssuredWorkloads\V1beta1\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\Client\AssuredWorkloadsServiceClient;

/**
* Analyze if the source Assured Workloads can be moved to the target Assured
Expand All @@ -43,10 +44,14 @@ function analyze_workload_move_sample(string $target): void
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();

// Prepare the request message.
$request = (new AnalyzeWorkloadMoveRequest())
->setTarget($target);

// Call the API and handle any network failures.
try {
/** @var AnalyzeWorkloadMoveResponse $response */
$response = $assuredWorkloadsServiceClient->analyzeWorkloadMove($target);
$response = $assuredWorkloadsServiceClient->analyzeWorkloadMove($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
// [START assuredworkloads_v1beta1_generated_AssuredWorkloadsService_CreateWorkload_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AssuredWorkloads\V1beta1\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\CreateWorkloadRequest;
use Google\Cloud\AssuredWorkloads\V1beta1\Workload;
use Google\Cloud\AssuredWorkloads\V1beta1\Workload\ComplianceRegime;
use Google\Rpc\Status;
Expand All @@ -52,15 +53,18 @@ function create_workload_sample(
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$workload = (new Workload())
->setDisplayName($workloadDisplayName)
->setComplianceRegime($workloadComplianceRegime);
$request = (new CreateWorkloadRequest())
->setParent($formattedParent)
->setWorkload($workload);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $assuredWorkloadsServiceClient->createWorkload($formattedParent, $workload);
$response = $assuredWorkloadsServiceClient->createWorkload($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START assuredworkloads_v1beta1_generated_AssuredWorkloadsService_DeleteWorkload_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AssuredWorkloads\V1beta1\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\DeleteWorkloadRequest;

/**
* Deletes the workload. Make sure that workload's direct children are already
Expand All @@ -44,9 +45,13 @@ function delete_workload_sample(string $formattedName): void
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();

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

// Call the API and handle any network failures.
try {
$assuredWorkloadsServiceClient->deleteWorkload($formattedName);
$assuredWorkloadsServiceClient->deleteWorkload($request);
printf('Call completed successfully.' . PHP_EOL);
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START assuredworkloads_v1beta1_generated_AssuredWorkloadsService_GetWorkload_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AssuredWorkloads\V1beta1\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\GetWorkloadRequest;
use Google\Cloud\AssuredWorkloads\V1beta1\Workload;

/**
Expand All @@ -42,10 +43,14 @@ function get_workload_sample(string $formattedName): void
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();

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

// Call the API and handle any network failures.
try {
/** @var Workload $response */
$response = $assuredWorkloadsServiceClient->getWorkload($formattedName);
$response = $assuredWorkloadsServiceClient->getWorkload($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
// [START assuredworkloads_v1beta1_generated_AssuredWorkloadsService_ListWorkloads_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AssuredWorkloads\V1beta1\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\ListWorkloadsRequest;
use Google\Cloud\AssuredWorkloads\V1beta1\Workload;

/**
Expand All @@ -40,10 +41,14 @@ function list_workloads_sample(string $formattedParent): void
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();

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

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

/** @var Workload $element */
foreach ($response as $element) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START assuredworkloads_v1beta1_generated_AssuredWorkloadsService_RestrictAllowedResources_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AssuredWorkloads\V1beta1\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\RestrictAllowedResourcesRequest;
use Google\Cloud\AssuredWorkloads\V1beta1\RestrictAllowedResourcesRequest\RestrictionType;
use Google\Cloud\AssuredWorkloads\V1beta1\RestrictAllowedResourcesResponse;

Expand All @@ -48,10 +49,15 @@ function restrict_allowed_resources_sample(string $name, int $restrictionType):
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();

// Prepare the request message.
$request = (new RestrictAllowedResourcesRequest())
->setName($name)
->setRestrictionType($restrictionType);

// Call the API and handle any network failures.
try {
/** @var RestrictAllowedResourcesResponse $response */
$response = $assuredWorkloadsServiceClient->restrictAllowedResources($name, $restrictionType);
$response = $assuredWorkloadsServiceClient->restrictAllowedResources($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START assuredworkloads_v1beta1_generated_AssuredWorkloadsService_UpdateWorkload_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AssuredWorkloads\V1beta1\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1beta1\UpdateWorkloadRequest;
use Google\Cloud\AssuredWorkloads\V1beta1\Workload;
use Google\Cloud\AssuredWorkloads\V1beta1\Workload\ComplianceRegime;
use Google\Protobuf\FieldMask;
Expand All @@ -48,16 +49,19 @@ function update_workload_sample(string $workloadDisplayName, int $workloadCompli
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$workload = (new Workload())
->setDisplayName($workloadDisplayName)
->setComplianceRegime($workloadComplianceRegime);
$updateMask = new FieldMask();
$request = (new UpdateWorkloadRequest())
->setWorkload($workload)
->setUpdateMask($updateMask);

// Call the API and handle any network failures.
try {
/** @var Workload $response */
$response = $assuredWorkloadsServiceClient->updateWorkload($workload, $updateMask);
$response = $assuredWorkloadsServiceClient->updateWorkload($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
Expand Down
Loading