Skip to content

Commit

Permalink
Merge branch 'main' into owl-bot-copy-Run
Browse files Browse the repository at this point in the history
  • Loading branch information
ajupazhamayil authored Sep 26, 2023
2 parents 7c15626 + ca23119 commit 53972e6
Show file tree
Hide file tree
Showing 196 changed files with 9,974 additions and 996 deletions.
Binary file modified AdvisoryNotifications/metadata/V1/Service.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?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 advisorynotifications_v1_generated_AdvisoryNotificationsService_GetSettings_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AdvisoryNotifications\V1\Client\AdvisoryNotificationsServiceClient;
use Google\Cloud\AdvisoryNotifications\V1\GetSettingsRequest;
use Google\Cloud\AdvisoryNotifications\V1\Settings;

/**
* Get notification settings.
*
* @param string $formattedName The resource name of the settings to retrieve.
* Format:
* organizations/{organization}/locations/{location}/settings. Please see
* {@see AdvisoryNotificationsServiceClient::settingsName()} for help formatting this field.
*/
function get_settings_sample(string $formattedName): void
{
// Create a client.
$advisoryNotificationsServiceClient = new AdvisoryNotificationsServiceClient();

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

// Call the API and handle any network failures.
try {
/** @var Settings $response */
$response = $advisoryNotificationsServiceClient->getSettings($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 = AdvisoryNotificationsServiceClient::settingsName('[ORGANIZATION]', '[LOCATION]');

get_settings_sample($formattedName);
}
// [END advisorynotifications_v1_generated_AdvisoryNotificationsService_GetSettings_sync]
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 advisorynotifications_v1_generated_AdvisoryNotificationsService_UpdateSettings_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AdvisoryNotifications\V1\Client\AdvisoryNotificationsServiceClient;
use Google\Cloud\AdvisoryNotifications\V1\Settings;
use Google\Cloud\AdvisoryNotifications\V1\UpdateSettingsRequest;

/**
* Update notification settings.
*
* @param string $settingsEtag Fingerprint for optimistic concurrency returned in Get requests.
* Must be provided for Update requests. If the value provided does not match
* the value known to the server, ABORTED will be thrown, and the client
* should retry the read-modify-write cycle.
*/
function update_settings_sample(string $settingsEtag): void
{
// Create a client.
$advisoryNotificationsServiceClient = new AdvisoryNotificationsServiceClient();

// Prepare the request message.
$settingsNotificationSettings = [];
$settings = (new Settings())
->setNotificationSettings($settingsNotificationSettings)
->setEtag($settingsEtag);
$request = (new UpdateSettingsRequest())
->setSettings($settings);

// Call the API and handle any network failures.
try {
/** @var Settings $response */
$response = $advisoryNotificationsServiceClient->updateSettings($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
{
$settingsEtag = '[ETAG]';

update_settings_sample($settingsEtag);
}
// [END advisorynotifications_v1_generated_AdvisoryNotificationsService_UpdateSettings_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
use Google\ApiCore\ValidationException;
use Google\Auth\FetchAuthTokenInterface;
use Google\Cloud\AdvisoryNotifications\V1\GetNotificationRequest;
use Google\Cloud\AdvisoryNotifications\V1\GetSettingsRequest;
use Google\Cloud\AdvisoryNotifications\V1\ListNotificationsRequest;
use Google\Cloud\AdvisoryNotifications\V1\Notification;
use Google\Cloud\AdvisoryNotifications\V1\Settings;
use Google\Cloud\AdvisoryNotifications\V1\UpdateSettingsRequest;
use GuzzleHttp\Promise\PromiseInterface;

/**
Expand All @@ -58,7 +61,9 @@
* @internal
*
* @method PromiseInterface getNotificationAsync(GetNotificationRequest $request, array $optionalArgs = [])
* @method PromiseInterface getSettingsAsync(GetSettingsRequest $request, array $optionalArgs = [])
* @method PromiseInterface listNotificationsAsync(ListNotificationsRequest $request, array $optionalArgs = [])
* @method PromiseInterface updateSettingsAsync(UpdateSettingsRequest $request, array $optionalArgs = [])
*/
abstract class AdvisoryNotificationsServiceBaseClient
{
Expand Down Expand Up @@ -137,12 +142,30 @@ public static function notificationName(string $organization, string $location,
]);
}

/**
* Formats a string containing the fully-qualified path to represent a settings
* resource.
*
* @param string $organization
* @param string $location
*
* @return string The formatted settings resource.
*/
public static function settingsName(string $organization, string $location): string
{
return self::getPathTemplate('settings')->render([
'organization' => $organization,
'location' => $location,
]);
}

/**
* Parses a formatted name string and returns an associative array of the components in the name.
* The following name formats are supported:
* Template: Pattern
* - location: organizations/{organization}/locations/{location}
* - notification: organizations/{organization}/locations/{location}/notifications/{notification}
* - settings: organizations/{organization}/locations/{location}/settings
*
* The optional $template argument can be supplied to specify a particular pattern,
* and must match one of the templates listed above. If no $template argument is
Expand Down Expand Up @@ -259,6 +282,32 @@ public function getNotification(GetNotificationRequest $request, array $callOpti
return $this->startApiCall('GetNotification', $request, $callOptions)->wait();
}

/**
* Get notification settings.
*
* The async variant is {@see self::getSettingsAsync()} .
*
* @example samples/V1/AdvisoryNotificationsServiceClient/get_settings.php
*
* @param GetSettingsRequest $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 Settings
*
* @throws ApiException Thrown if the API call fails.
*/
public function getSettings(GetSettingsRequest $request, array $callOptions = []): Settings
{
return $this->startApiCall('GetSettings', $request, $callOptions)->wait();
}

/**
* Lists notifications under a given parent.
*
Expand All @@ -284,4 +333,30 @@ public function listNotifications(ListNotificationsRequest $request, array $call
{
return $this->startApiCall('ListNotifications', $request, $callOptions);
}

/**
* Update notification settings.
*
* The async variant is {@see self::updateSettingsAsync()} .
*
* @example samples/V1/AdvisoryNotificationsServiceClient/update_settings.php
*
* @param UpdateSettingsRequest $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 Settings
*
* @throws ApiException Thrown if the API call fails.
*/
public function updateSettings(UpdateSettingsRequest $request, array $callOptions = []): Settings
{
return $this->startApiCall('UpdateSettings', $request, $callOptions)->wait();
}
}
Loading

0 comments on commit 53972e6

Please sign in to comment.