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\BigQueryReservation\Resource;
19
20use Google\Service\BigQueryReservation\BigqueryreservationEmpty;
21use Google\Service\BigQueryReservation\CapacityCommitment;
22use Google\Service\BigQueryReservation\ListCapacityCommitmentsResponse;
23use Google\Service\BigQueryReservation\MergeCapacityCommitmentsRequest;
24use Google\Service\BigQueryReservation\SplitCapacityCommitmentRequest;
25use Google\Service\BigQueryReservation\SplitCapacityCommitmentResponse;
26
27/**
28 * The "capacityCommitments" collection of methods.
29 * Typical usage is:
30 *  <code>
31 *   $bigqueryreservationService = new Google\Service\BigQueryReservation(...);
32 *   $capacityCommitments = $bigqueryreservationService->capacityCommitments;
33 *  </code>
34 */
35class ProjectsLocationsCapacityCommitments extends \Google\Service\Resource
36{
37  /**
38   * Creates a new capacity commitment resource. (capacityCommitments.create)
39   *
40   * @param string $parent Required. Resource name of the parent reservation.
41   * E.g., `projects/myproject/locations/US`
42   * @param CapacityCommitment $postBody
43   * @param array $optParams Optional parameters.
44   *
45   * @opt_param string capacityCommitmentId The optional capacity commitment ID.
46   * Capacity commitment name will be generated automatically if this field is
47   * empty. This field must only contain lower case alphanumeric characters or
48   * dashes. The first and last character cannot be a dash. Max length is 64
49   * characters. NOTE: this ID won't be kept if the capacity commitment is split
50   * or merged.
51   * @opt_param bool enforceSingleAdminProjectPerOrg If true, fail the request if
52   * another project in the organization has a capacity commitment.
53   * @return CapacityCommitment
54   */
55  public function create($parent, CapacityCommitment $postBody, $optParams = [])
56  {
57    $params = ['parent' => $parent, 'postBody' => $postBody];
58    $params = array_merge($params, $optParams);
59    return $this->call('create', [$params], CapacityCommitment::class);
60  }
61  /**
62   * Deletes a capacity commitment. Attempting to delete capacity commitment
63   * before its commitment_end_time will fail with the error code
64   * `google.rpc.Code.FAILED_PRECONDITION`. (capacityCommitments.delete)
65   *
66   * @param string $name Required. Resource name of the capacity commitment to
67   * delete. E.g., `projects/myproject/locations/US/capacityCommitments/123`
68   * @param array $optParams Optional parameters.
69   *
70   * @opt_param bool force Can be used to force delete commitments even if
71   * assignments exist. Deleting commitments with assignments may cause queries to
72   * fail if they no longer have access to slots.
73   * @return BigqueryreservationEmpty
74   */
75  public function delete($name, $optParams = [])
76  {
77    $params = ['name' => $name];
78    $params = array_merge($params, $optParams);
79    return $this->call('delete', [$params], BigqueryreservationEmpty::class);
80  }
81  /**
82   * Returns information about the capacity commitment. (capacityCommitments.get)
83   *
84   * @param string $name Required. Resource name of the capacity commitment to
85   * retrieve. E.g., `projects/myproject/locations/US/capacityCommitments/123`
86   * @param array $optParams Optional parameters.
87   * @return CapacityCommitment
88   */
89  public function get($name, $optParams = [])
90  {
91    $params = ['name' => $name];
92    $params = array_merge($params, $optParams);
93    return $this->call('get', [$params], CapacityCommitment::class);
94  }
95  /**
96   * Lists all the capacity commitments for the admin project.
97   * (capacityCommitments.listProjectsLocationsCapacityCommitments)
98   *
99   * @param string $parent Required. Resource name of the parent reservation.
100   * E.g., `projects/myproject/locations/US`
101   * @param array $optParams Optional parameters.
102   *
103   * @opt_param int pageSize The maximum number of items to return.
104   * @opt_param string pageToken The next_page_token value returned from a
105   * previous List request, if any.
106   * @return ListCapacityCommitmentsResponse
107   */
108  public function listProjectsLocationsCapacityCommitments($parent, $optParams = [])
109  {
110    $params = ['parent' => $parent];
111    $params = array_merge($params, $optParams);
112    return $this->call('list', [$params], ListCapacityCommitmentsResponse::class);
113  }
114  /**
115   * Merges capacity commitments of the same plan into a single commitment. The
116   * resulting capacity commitment has the greater commitment_end_time out of the
117   * to-be-merged capacity commitments. Attempting to merge capacity commitments
118   * of different plan will fail with the error code
119   * `google.rpc.Code.FAILED_PRECONDITION`. (capacityCommitments.merge)
120   *
121   * @param string $parent Parent resource that identifies admin project and
122   * location e.g., `projects/myproject/locations/us`
123   * @param MergeCapacityCommitmentsRequest $postBody
124   * @param array $optParams Optional parameters.
125   * @return CapacityCommitment
126   */
127  public function merge($parent, MergeCapacityCommitmentsRequest $postBody, $optParams = [])
128  {
129    $params = ['parent' => $parent, 'postBody' => $postBody];
130    $params = array_merge($params, $optParams);
131    return $this->call('merge', [$params], CapacityCommitment::class);
132  }
133  /**
134   * Updates an existing capacity commitment. Only `plan` and `renewal_plan`
135   * fields can be updated. Plan can only be changed to a plan of a longer
136   * commitment period. Attempting to change to a plan with shorter commitment
137   * period will fail with the error code `google.rpc.Code.FAILED_PRECONDITION`.
138   * (capacityCommitments.patch)
139   *
140   * @param string $name Output only. The resource name of the capacity
141   * commitment, e.g., `projects/myproject/locations/US/capacityCommitments/123`
142   * The commitment_id must only contain lower case alphanumeric characters or
143   * dashes. It must start with a letter and must not end with a dash. Its maximum
144   * length is 64 characters.
145   * @param CapacityCommitment $postBody
146   * @param array $optParams Optional parameters.
147   *
148   * @opt_param string updateMask Standard field mask for the set of fields to be
149   * updated.
150   * @return CapacityCommitment
151   */
152  public function patch($name, CapacityCommitment $postBody, $optParams = [])
153  {
154    $params = ['name' => $name, 'postBody' => $postBody];
155    $params = array_merge($params, $optParams);
156    return $this->call('patch', [$params], CapacityCommitment::class);
157  }
158  /**
159   * Splits capacity commitment to two commitments of the same plan and
160   * `commitment_end_time`. A common use case is to enable downgrading
161   * commitments. For example, in order to downgrade from 10000 slots to 8000, you
162   * might split a 10000 capacity commitment into commitments of 2000 and 8000.
163   * Then, you delete the first one after the commitment end time passes.
164   * (capacityCommitments.split)
165   *
166   * @param string $name Required. The resource name e.g.,:
167   * `projects/myproject/locations/US/capacityCommitments/123`
168   * @param SplitCapacityCommitmentRequest $postBody
169   * @param array $optParams Optional parameters.
170   * @return SplitCapacityCommitmentResponse
171   */
172  public function split($name, SplitCapacityCommitmentRequest $postBody, $optParams = [])
173  {
174    $params = ['name' => $name, 'postBody' => $postBody];
175    $params = array_merge($params, $optParams);
176    return $this->call('split', [$params], SplitCapacityCommitmentResponse::class);
177  }
178}
179
180// Adding a class alias for backwards compatibility with the previous class name.
181class_alias(ProjectsLocationsCapacityCommitments::class, 'Google_Service_BigQueryReservation_Resource_ProjectsLocationsCapacityCommitments');
182