-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Order modification RPCs and License Management Service (#7729)
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
1 parent
c4a0d8d
commit 3252d24
Showing
42 changed files
with
4,255 additions
and
28 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file modified
BIN
+1.41 KB
(150%)
CommerceConsumerProcurement/metadata/V1/ProcurementService.php
Binary file not shown.
84 changes: 84 additions & 0 deletions
84
CommerceConsumerProcurement/samples/V1/ConsumerProcurementServiceClient/cancel_order.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
83 changes: 83 additions & 0 deletions
83
CommerceConsumerProcurement/samples/V1/ConsumerProcurementServiceClient/modify_order.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
75 changes: 75 additions & 0 deletions
75
CommerceConsumerProcurement/samples/V1/LicenseManagementServiceClient/assign.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@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] |
75 changes: 75 additions & 0 deletions
75
...onsumerProcurement/samples/V1/LicenseManagementServiceClient/enumerate_licensed_users.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
71 changes: 71 additions & 0 deletions
71
CommerceConsumerProcurement/samples/V1/LicenseManagementServiceClient/get_license_pool.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
Oops, something went wrong.