Skip to content

Commit

Permalink
feat: add Order modification RPCs and License Management Service (#7729)
Browse files Browse the repository at this point in the history
docs: A comment for enum value `LINE_ITEM_CHANGE_STATE_PENDING_APPROVAL` in enum `LineItemChangeState` is changed
docs: A comment for enum value `LINE_ITEM_CHANGE_STATE_APPROVED` in enum `LineItemChangeState` is changed
docs: A comment for enum value `LINE_ITEM_CHANGE_STATE_COMPLETED` in enum `LineItemChangeState` is changed
docs: A comment for enum value `LINE_ITEM_CHANGE_STATE_REJECTED` in enum `LineItemChangeState` is changed
docs: A comment for enum value `LINE_ITEM_CHANGE_STATE_ABANDONED` in enum `LineItemChangeState` is changed
docs: A comment for enum value `LINE_ITEM_CHANGE_STATE_ACTIVATING` in enum `LineItemChangeState` is changed
docs: A comment for field `request_id` in message `.google.cloud.commerce.consumer.procurement.v1.PlaceOrderRequest` is changed
docs: A comment for field `filter` in message `.google.cloud.commerce.consumer.procurement.v1.ListOrdersRequest` is changed
PiperOrigin-RevId: 682457622
Source-Link: googleapis/googleapis@1f8352c
Source-Link: googleapis/googleapis-gen@1727200
Copy-Tag: eyJwIjoiQ29tbWVyY2VDb25zdW1lclByb2N1cmVtZW50Ly5Pd2xCb3QueWFtbCIsImgiOiIxNzI3MjAwNjhmMjI1OWIzNjVhNTZhMjJhMGM3YzJhNmQ0NDZjNzMyIn0=
  • Loading branch information
gcf-owl-bot[bot] authored Oct 11, 2024
1 parent c4a0d8d commit 3252d24
Show file tree
Hide file tree
Showing 42 changed files with 4,255 additions and 28 deletions.
Binary file not shown.
Binary file modified CommerceConsumerProcurement/metadata/V1/ProcurementService.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?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 cloudcommerceconsumerprocurement_v1_generated_ConsumerProcurementService_CancelOrder_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Commerce\Consumer\Procurement\V1\CancelOrderRequest;
use Google\Cloud\Commerce\Consumer\Procurement\V1\Client\ConsumerProcurementServiceClient;
use Google\Cloud\Commerce\Consumer\Procurement\V1\Order;
use Google\Rpc\Status;

/**
* Cancels an existing
* [Order][google.cloud.commerce.consumer.procurement.v1.Order]. Every product
* procured in the Order will be cancelled.
*
* @param string $name The resource name of the order.
*/
function cancel_order_sample(string $name): void
{
// Create a client.
$consumerProcurementServiceClient = new ConsumerProcurementServiceClient();

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

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

if ($response->operationSucceeded()) {
/** @var Order $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
{
$name = '[NAME]';

cancel_order_sample($name);
}
// [END cloudcommerceconsumerprocurement_v1_generated_ConsumerProcurementService_CancelOrder_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?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 cloudcommerceconsumerprocurement_v1_generated_ConsumerProcurementService_ModifyOrder_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Commerce\Consumer\Procurement\V1\Client\ConsumerProcurementServiceClient;
use Google\Cloud\Commerce\Consumer\Procurement\V1\ModifyOrderRequest;
use Google\Cloud\Commerce\Consumer\Procurement\V1\Order;
use Google\Rpc\Status;

/**
* Modifies an existing
* [Order][google.cloud.commerce.consumer.procurement.v1.Order] resource.
*
* @param string $name Name of the order to update.
*/
function modify_order_sample(string $name): void
{
// Create a client.
$consumerProcurementServiceClient = new ConsumerProcurementServiceClient();

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

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

if ($response->operationSucceeded()) {
/** @var Order $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
{
$name = '[NAME]';

modify_order_sample($name);
}
// [END cloudcommerceconsumerprocurement_v1_generated_ConsumerProcurementService_ModifyOrder_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?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 cloudcommerceconsumerprocurement_v1_generated_LicenseManagementService_Assign_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Commerce\Consumer\Procurement\V1\AssignRequest;
use Google\Cloud\Commerce\Consumer\Procurement\V1\AssignResponse;
use Google\Cloud\Commerce\Consumer\Procurement\V1\Client\LicenseManagementServiceClient;

/**
* Assigns a license to a user.
*
* @param string $parent License pool name.
* @param string $usernamesElement Username.
* Format: `name&#64;domain.com`.
*/
function assign_sample(string $parent, string $usernamesElement): void
{
// Create a client.
$licenseManagementServiceClient = new LicenseManagementServiceClient();

// Prepare the request message.
$usernames = [$usernamesElement,];
$request = (new AssignRequest())
->setParent($parent)
->setUsernames($usernames);

// Call the API and handle any network failures.
try {
/** @var AssignResponse $response */
$response = $licenseManagementServiceClient->assign($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
{
$parent = '[PARENT]';
$usernamesElement = '[USERNAMES]';

assign_sample($parent, $usernamesElement);
}
// [END cloudcommerceconsumerprocurement_v1_generated_LicenseManagementService_Assign_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?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 cloudcommerceconsumerprocurement_v1_generated_LicenseManagementService_EnumerateLicensedUsers_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Commerce\Consumer\Procurement\V1\Client\LicenseManagementServiceClient;
use Google\Cloud\Commerce\Consumer\Procurement\V1\EnumerateLicensedUsersRequest;
use Google\Cloud\Commerce\Consumer\Procurement\V1\LicensedUser;

/**
* Enumerates all users assigned a license.
*
* @param string $parent License pool name.
*/
function enumerate_licensed_users_sample(string $parent): void
{
// Create a client.
$licenseManagementServiceClient = new LicenseManagementServiceClient();

// Prepare the request message.
$request = (new EnumerateLicensedUsersRequest())
->setParent($parent);

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

/** @var LicensedUser $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
{
$parent = '[PARENT]';

enumerate_licensed_users_sample($parent);
}
// [END cloudcommerceconsumerprocurement_v1_generated_LicenseManagementService_EnumerateLicensedUsers_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?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 cloudcommerceconsumerprocurement_v1_generated_LicenseManagementService_GetLicensePool_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Commerce\Consumer\Procurement\V1\Client\LicenseManagementServiceClient;
use Google\Cloud\Commerce\Consumer\Procurement\V1\GetLicensePoolRequest;
use Google\Cloud\Commerce\Consumer\Procurement\V1\LicensePool;

/**
* Gets the license pool.
*
* @param string $name The name of the license pool to get.
* Format: `billingAccounts/{billing_account}/orders/{order}/licensePool`
*/
function get_license_pool_sample(string $name): void
{
// Create a client.
$licenseManagementServiceClient = new LicenseManagementServiceClient();

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

// Call the API and handle any network failures.
try {
/** @var LicensePool $response */
$response = $licenseManagementServiceClient->getLicensePool($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
{
$name = '[NAME]';

get_license_pool_sample($name);
}
// [END cloudcommerceconsumerprocurement_v1_generated_LicenseManagementService_GetLicensePool_sync]
Loading

0 comments on commit 3252d24

Please sign in to comment.