forked from googleapis/google-cloud-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added the MoveBillingAccount method, which allows changing whic…
…h organization a billing account belongs to (googleapis#6845) feat: added field BillingAccount.parent build: do not use common_resources.proto for Billing v1 API The change to BUILD.bazel should not affect any library users. We will define Project and Organization resources in the Billing proto instead of the common proto file. PiperOrigin-RevId: 588132546 Source-Link: googleapis/googleapis@3ab9a05 Source-Link: https://github.com/googleapis/googleapis-gen/commit/6cdd705c1da9da4c30fe46194a0279ced722cc54 Copy-Tag: eyJwIjoiQmlsbGluZy8uT3dsQm90LnlhbWwiLCJoIjoiNmNkZDcwNWMxZGE5ZGE0YzMwZmU0NjE5NGEwMjc5Y2VkNzIyY2M1NCJ9
- Loading branch information
1 parent
67eb6c7
commit 73ea346
Showing
15 changed files
with
918 additions
and
8 deletions.
There are no files selected for viewing
Binary file not shown.
76 changes: 76 additions & 0 deletions
76
Billing/samples/V1/CloudBillingClient/move_billing_account.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,76 @@ | ||
<?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 cloudbilling_v1_generated_CloudBilling_MoveBillingAccount_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Billing\V1\BillingAccount; | ||
use Google\Cloud\Billing\V1\CloudBillingClient; | ||
|
||
/** | ||
* Changes which parent organization a billing account belongs to. | ||
* | ||
* @param string $formattedName The resource name of the billing account to move. | ||
* Must be of the form `billingAccounts/{billing_account_id}`. | ||
* The specified billing account cannot be a subaccount, since a subaccount | ||
* always belongs to the same organization as its parent account. Please see | ||
* {@see CloudBillingClient::billingAccountName()} for help formatting this field. | ||
* @param string $formattedDestinationParent The resource name of the Organization to reparent | ||
* the billing account under. | ||
* Must be of the form `organizations/{organization_id}`. Please see | ||
* {@see CloudBillingClient::organizationName()} for help formatting this field. | ||
*/ | ||
function move_billing_account_sample( | ||
string $formattedName, | ||
string $formattedDestinationParent | ||
): void { | ||
// Create a client. | ||
$cloudBillingClient = new CloudBillingClient(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var BillingAccount $response */ | ||
$response = $cloudBillingClient->moveBillingAccount($formattedName, $formattedDestinationParent); | ||
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 = CloudBillingClient::billingAccountName('[BILLING_ACCOUNT]'); | ||
$formattedDestinationParent = CloudBillingClient::organizationName('[ORGANIZATION]'); | ||
|
||
move_billing_account_sample($formattedName, $formattedDestinationParent); | ||
} | ||
// [END cloudbilling_v1_generated_CloudBilling_MoveBillingAccount_sync] |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.