Skip to content

Commit

Permalink
feat: add new client surface to preview clients (#6207)
Browse files Browse the repository at this point in the history
chore: regenerate API index
Source-Link: googleapis/googleapis@a012f7c
Source-Link: googleapis/googleapis-gen@3dfb33d
Copy-Tag: eyJwIjoiQ29udGFpbmVyQW5hbHlzaXMvLk93bEJvdC55YW1sIiwiaCI6IjNkZmIzM2RiNDNjYTJkMWY1MmFjODRhNjQ2MGE1NTlhZWNiZGZkMTcifQ==
  • Loading branch information
gcf-owl-bot[bot] authored May 10, 2023
1 parent 9a72b60 commit 125110f
Show file tree
Hide file tree
Showing 9 changed files with 848 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// [START containeranalysis_v1_generated_ContainerAnalysis_GetIamPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\ContainerAnalysis\V1\ContainerAnalysisClient;
use Google\Cloud\ContainerAnalysis\V1\Client\ContainerAnalysisClient;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;

/**
Expand All @@ -45,10 +46,14 @@ function get_iam_policy_sample(string $resource): void
// Create a client.
$containerAnalysisClient = new ContainerAnalysisClient();

// Prepare the request message.
$request = (new GetIamPolicyRequest())
->setResource($resource);

// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $containerAnalysisClient->getIamPolicy($resource);
$response = $containerAnalysisClient->getIamPolicy($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 containeranalysis_v1_generated_ContainerAnalysis_GetVulnerabilityOccurrencesSummary_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\ContainerAnalysis\V1\ContainerAnalysisClient;
use Google\Cloud\ContainerAnalysis\V1\Client\ContainerAnalysisClient;
use Google\Cloud\ContainerAnalysis\V1\GetVulnerabilityOccurrencesSummaryRequest;
use Google\Cloud\ContainerAnalysis\V1\VulnerabilityOccurrencesSummary;

/**
Expand All @@ -39,10 +40,14 @@ function get_vulnerability_occurrences_summary_sample(string $formattedParent):
// Create a client.
$containerAnalysisClient = new ContainerAnalysisClient();

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

// Call the API and handle any network failures.
try {
/** @var VulnerabilityOccurrencesSummary $response */
$response = $containerAnalysisClient->getVulnerabilityOccurrencesSummary($formattedParent);
$response = $containerAnalysisClient->getVulnerabilityOccurrencesSummary($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,8 +24,9 @@

// [START containeranalysis_v1_generated_ContainerAnalysis_SetIamPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\ContainerAnalysis\V1\ContainerAnalysisClient;
use Google\Cloud\ContainerAnalysis\V1\Client\ContainerAnalysisClient;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\Iam\V1\SetIamPolicyRequest;

/**
* Sets the access control policy on the specified note or occurrence.
Expand All @@ -45,13 +46,16 @@ function set_iam_policy_sample(string $resource): void
// Create a client.
$containerAnalysisClient = new ContainerAnalysisClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$policy = new Policy();
$request = (new SetIamPolicyRequest())
->setResource($resource)
->setPolicy($policy);

// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $containerAnalysisClient->setIamPolicy($resource, $policy);
$response = $containerAnalysisClient->setIamPolicy($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 containeranalysis_v1_generated_ContainerAnalysis_TestIamPermissions_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\ContainerAnalysis\V1\ContainerAnalysisClient;
use Google\Cloud\ContainerAnalysis\V1\Client\ContainerAnalysisClient;
use Google\Cloud\Iam\V1\TestIamPermissionsRequest;
use Google\Cloud\Iam\V1\TestIamPermissionsResponse;

/**
Expand All @@ -48,13 +49,16 @@ function test_iam_permissions_sample(string $resource, string $permissionsElemen
// Create a client.
$containerAnalysisClient = new ContainerAnalysisClient();

// Prepare any non-scalar elements to be passed along with the request.
// Prepare the request message.
$permissions = [$permissionsElement,];
$request = (new TestIamPermissionsRequest())
->setResource($resource)
->setPermissions($permissions);

// Call the API and handle any network failures.
try {
/** @var TestIamPermissionsResponse $response */
$response = $containerAnalysisClient->testIamPermissions($resource, $permissions);
$response = $containerAnalysisClient->testIamPermissions($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

0 comments on commit 125110f

Please sign in to comment.