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 |
|
---|
18 | namespace Google\Service\Cloudbilling\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\Cloudbilling\ProjectBillingInfo;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * The "projects" collection of methods.
|
---|
24 | * Typical usage is:
|
---|
25 | * <code>
|
---|
26 | * $cloudbillingService = new Google\Service\Cloudbilling(...);
|
---|
27 | * $projects = $cloudbillingService->projects;
|
---|
28 | * </code>
|
---|
29 | */
|
---|
30 | class Projects extends \Google\Service\Resource
|
---|
31 | {
|
---|
32 | /**
|
---|
33 | * Gets the billing information for a project. The current authenticated user
|
---|
34 | * must have the `resourcemanager.projects.get` permission for the project,
|
---|
35 | * which can be granted by assigning the [Project
|
---|
36 | * Viewer](https://cloud.google.com/iam/docs/understanding-
|
---|
37 | * roles#predefined_roles) role. (projects.getBillingInfo)
|
---|
38 | *
|
---|
39 | * @param string $name Required. The resource name of the project for which
|
---|
40 | * billing information is retrieved. For example, `projects/tokyo-rain-123`.
|
---|
41 | * @param array $optParams Optional parameters.
|
---|
42 | * @return ProjectBillingInfo
|
---|
43 | * @throws \Google\Service\Exception
|
---|
44 | */
|
---|
45 | public function getBillingInfo($name, $optParams = [])
|
---|
46 | {
|
---|
47 | $params = ['name' => $name];
|
---|
48 | $params = array_merge($params, $optParams);
|
---|
49 | return $this->call('getBillingInfo', [$params], ProjectBillingInfo::class);
|
---|
50 | }
|
---|
51 | /**
|
---|
52 | * Sets or updates the billing account associated with a project. You specify
|
---|
53 | * the new billing account by setting the `billing_account_name` in the
|
---|
54 | * `ProjectBillingInfo` resource to the resource name of a billing account.
|
---|
55 | * Associating a project with an open billing account enables billing on the
|
---|
56 | * project and allows charges for resource usage. If the project already had a
|
---|
57 | * billing account, this method changes the billing account used for resource
|
---|
58 | * usage charges. *Note:* Incurred charges that have not yet been reported in
|
---|
59 | * the transaction history of the Google Cloud Console might be billed to the
|
---|
60 | * new billing account, even if the charge occurred before the new billing
|
---|
61 | * account was assigned to the project. The current authenticated user must have
|
---|
62 | * ownership privileges for both the
|
---|
63 | * [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo )
|
---|
64 | * and the [billing account](https://cloud.google.com/billing/docs/how-
|
---|
65 | * to/billing-access). You can disable billing on the project by setting the
|
---|
66 | * `billing_account_name` field to empty. This action disassociates the current
|
---|
67 | * billing account from the project. Any billable activity of your in-use
|
---|
68 | * services will stop, and your application could stop functioning as expected.
|
---|
69 | * Any unbilled charges to date will be billed to the previously associated
|
---|
70 | * account. The current authenticated user must be either an owner of the
|
---|
71 | * project or an owner of the billing account for the project. Note that
|
---|
72 | * associating a project with a *closed* billing account will have much the same
|
---|
73 | * effect as disabling billing on the project: any paid resources used by the
|
---|
74 | * project will be shut down. Thus, unless you wish to disable billing, you
|
---|
75 | * should always call this method with the name of an *open* billing account.
|
---|
76 | * (projects.updateBillingInfo)
|
---|
77 | *
|
---|
78 | * @param string $name Required. The resource name of the project associated
|
---|
79 | * with the billing information that you want to update. For example,
|
---|
80 | * `projects/tokyo-rain-123`.
|
---|
81 | * @param ProjectBillingInfo $postBody
|
---|
82 | * @param array $optParams Optional parameters.
|
---|
83 | * @return ProjectBillingInfo
|
---|
84 | * @throws \Google\Service\Exception
|
---|
85 | */
|
---|
86 | public function updateBillingInfo($name, ProjectBillingInfo $postBody, $optParams = [])
|
---|
87 | {
|
---|
88 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
89 | $params = array_merge($params, $optParams);
|
---|
90 | return $this->call('updateBillingInfo', [$params], ProjectBillingInfo::class);
|
---|
91 | }
|
---|
92 | }
|
---|
93 |
|
---|
94 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
95 | class_alias(Projects::class, 'Google_Service_Cloudbilling_Resource_Projects');
|
---|