1<?php 2/* 3 * Copyright 2014 Google Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 * use this file except in compliance with the License. You may obtain a copy of 7 * the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 * License for the specific language governing permissions and limitations under 15 * the License. 16 */ 17 18namespace Google\Service\Cloudbilling\Resource; 19 20use Google\Service\Cloudbilling\BillingAccount; 21use Google\Service\Cloudbilling\ListBillingAccountsResponse; 22use Google\Service\Cloudbilling\Policy; 23use Google\Service\Cloudbilling\SetIamPolicyRequest; 24use Google\Service\Cloudbilling\TestIamPermissionsRequest; 25use Google\Service\Cloudbilling\TestIamPermissionsResponse; 26 27/** 28 * The "billingAccounts" collection of methods. 29 * Typical usage is: 30 * <code> 31 * $cloudbillingService = new Google\Service\Cloudbilling(...); 32 * $billingAccounts = $cloudbillingService->billingAccounts; 33 * </code> 34 */ 35class BillingAccounts extends \Google\Service\Resource 36{ 37 /** 38 * This method creates [billing 39 * subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). 40 * Google Cloud resellers should use the Channel Services APIs, [accounts.custom 41 * ers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts. 42 * customers/create) and [accounts.customers.entitlements.create](https://cloud. 43 * google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/cre 44 * ate). When creating a subaccount, the current authenticated user must have 45 * the `billing.accounts.update` IAM permission on the parent account, which is 46 * typically given to billing account 47 * [administrators](https://cloud.google.com/billing/docs/how-to/billing- 48 * access). This method will return an error if the parent account has not been 49 * provisioned as a reseller account. (billingAccounts.create) 50 * 51 * @param BillingAccount $postBody 52 * @param array $optParams Optional parameters. 53 * @return BillingAccount 54 */ 55 public function create(BillingAccount $postBody, $optParams = []) 56 { 57 $params = ['postBody' => $postBody]; 58 $params = array_merge($params, $optParams); 59 return $this->call('create', [$params], BillingAccount::class); 60 } 61 /** 62 * Gets information about a billing account. The current authenticated user must 63 * be a [viewer of the billing account](https://cloud.google.com/billing/docs 64 * /how-to/billing-access). (billingAccounts.get) 65 * 66 * @param string $name Required. The resource name of the billing account to 67 * retrieve. For example, `billingAccounts/012345-567890-ABCDEF`. 68 * @param array $optParams Optional parameters. 69 * @return BillingAccount 70 */ 71 public function get($name, $optParams = []) 72 { 73 $params = ['name' => $name]; 74 $params = array_merge($params, $optParams); 75 return $this->call('get', [$params], BillingAccount::class); 76 } 77 /** 78 * Gets the access control policy for a billing account. The caller must have 79 * the `billing.accounts.getIamPolicy` permission on the account, which is often 80 * given to billing account [viewers](https://cloud.google.com/billing/docs/how- 81 * to/billing-access). (billingAccounts.getIamPolicy) 82 * 83 * @param string $resource REQUIRED: The resource for which the policy is being 84 * requested. See the operation documentation for the appropriate value for this 85 * field. 86 * @param array $optParams Optional parameters. 87 * 88 * @opt_param int options.requestedPolicyVersion Optional. The maximum policy 89 * version that will be used to format the policy. Valid values are 0, 1, and 3. 90 * Requests specifying an invalid value will be rejected. Requests for policies 91 * with any conditional role bindings must specify version 3. Policies with no 92 * conditional role bindings may specify any valid value or leave the field 93 * unset. The policy in the response might use the policy version that you 94 * specified, or it might use a lower policy version. For example, if you 95 * specify version 3, but the policy has no conditional role bindings, the 96 * response uses version 1. To learn which resources support conditions in their 97 * IAM policies, see the [IAM 98 * documentation](https://cloud.google.com/iam/help/conditions/resource- 99 * policies). 100 * @return Policy 101 */ 102 public function getIamPolicy($resource, $optParams = []) 103 { 104 $params = ['resource' => $resource]; 105 $params = array_merge($params, $optParams); 106 return $this->call('getIamPolicy', [$params], Policy::class); 107 } 108 /** 109 * Lists the billing accounts that the current authenticated user has permission 110 * to [view](https://cloud.google.com/billing/docs/how-to/billing-access). 111 * (billingAccounts.listBillingAccounts) 112 * 113 * @param array $optParams Optional parameters. 114 * 115 * @opt_param string filter Options for how to filter the returned billing 116 * accounts. Currently this only supports filtering for 117 * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a single 118 * provided reseller billing account. (e.g. 119 * "master_billing_account=billingAccounts/012345-678901-ABCDEF"). Boolean 120 * algebra and other fields are not currently supported. 121 * @opt_param int pageSize Requested page size. The maximum page size is 100; 122 * this is also the default. 123 * @opt_param string pageToken A token identifying a page of results to return. 124 * This should be a `next_page_token` value returned from a previous 125 * `ListBillingAccounts` call. If unspecified, the first page of results is 126 * returned. 127 * @return ListBillingAccountsResponse 128 */ 129 public function listBillingAccounts($optParams = []) 130 { 131 $params = []; 132 $params = array_merge($params, $optParams); 133 return $this->call('list', [$params], ListBillingAccountsResponse::class); 134 } 135 /** 136 * Updates a billing account's fields. Currently the only field that can be 137 * edited is `display_name`. The current authenticated user must have the 138 * `billing.accounts.update` IAM permission, which is typically given to the 139 * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) 140 * of the billing account. (billingAccounts.patch) 141 * 142 * @param string $name Required. The name of the billing account resource to be 143 * updated. 144 * @param BillingAccount $postBody 145 * @param array $optParams Optional parameters. 146 * 147 * @opt_param string updateMask The update mask applied to the resource. Only 148 * "display_name" is currently supported. 149 * @return BillingAccount 150 */ 151 public function patch($name, BillingAccount $postBody, $optParams = []) 152 { 153 $params = ['name' => $name, 'postBody' => $postBody]; 154 $params = array_merge($params, $optParams); 155 return $this->call('patch', [$params], BillingAccount::class); 156 } 157 /** 158 * Sets the access control policy for a billing account. Replaces any existing 159 * policy. The caller must have the `billing.accounts.setIamPolicy` permission 160 * on the account, which is often given to billing account 161 * [administrators](https://cloud.google.com/billing/docs/how-to/billing- 162 * access). (billingAccounts.setIamPolicy) 163 * 164 * @param string $resource REQUIRED: The resource for which the policy is being 165 * specified. See the operation documentation for the appropriate value for this 166 * field. 167 * @param SetIamPolicyRequest $postBody 168 * @param array $optParams Optional parameters. 169 * @return Policy 170 */ 171 public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = []) 172 { 173 $params = ['resource' => $resource, 'postBody' => $postBody]; 174 $params = array_merge($params, $optParams); 175 return $this->call('setIamPolicy', [$params], Policy::class); 176 } 177 /** 178 * Tests the access control policy for a billing account. This method takes the 179 * resource and a set of permissions as input and returns the subset of the 180 * input permissions that the caller is allowed for that resource. 181 * (billingAccounts.testIamPermissions) 182 * 183 * @param string $resource REQUIRED: The resource for which the policy detail is 184 * being requested. See the operation documentation for the appropriate value 185 * for this field. 186 * @param TestIamPermissionsRequest $postBody 187 * @param array $optParams Optional parameters. 188 * @return TestIamPermissionsResponse 189 */ 190 public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = []) 191 { 192 $params = ['resource' => $resource, 'postBody' => $postBody]; 193 $params = array_merge($params, $optParams); 194 return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class); 195 } 196} 197 198// Adding a class alias for backwards compatibility with the previous class name. 199class_alias(BillingAccounts::class, 'Google_Service_Cloudbilling_Resource_BillingAccounts'); 200