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