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\ServiceConsumerManagement\Resource;
19
20use Google\Service\ServiceConsumerManagement\AddTenantProjectRequest;
21use Google\Service\ServiceConsumerManagement\ApplyTenantProjectConfigRequest;
22use Google\Service\ServiceConsumerManagement\AttachTenantProjectRequest;
23use Google\Service\ServiceConsumerManagement\CreateTenancyUnitRequest;
24use Google\Service\ServiceConsumerManagement\DeleteTenantProjectRequest;
25use Google\Service\ServiceConsumerManagement\ListTenancyUnitsResponse;
26use Google\Service\ServiceConsumerManagement\Operation;
27use Google\Service\ServiceConsumerManagement\RemoveTenantProjectRequest;
28use Google\Service\ServiceConsumerManagement\TenancyUnit;
29use Google\Service\ServiceConsumerManagement\UndeleteTenantProjectRequest;
30
31/**
32 * The "tenancyUnits" collection of methods.
33 * Typical usage is:
34 *  <code>
35 *   $serviceconsumermanagementService = new Google\Service\ServiceConsumerManagement(...);
36 *   $tenancyUnits = $serviceconsumermanagementService->tenancyUnits;
37 *  </code>
38 */
39class ServicesTenancyUnits extends \Google\Service\Resource
40{
41  /**
42   * Add a new tenant project to the tenancy unit. There can be a maximum of 1024
43   * tenant projects in a tenancy unit. If there are previously failed
44   * `AddTenantProject` calls, you might need to call `RemoveTenantProject` first
45   * to resolve them before you can make another call to `AddTenantProject` with
46   * the same tag. Operation. (tenancyUnits.addProject)
47   *
48   * @param string $parent Required. Name of the tenancy unit. Such as
49   * 'services/service.googleapis.com/projects/12345/tenancyUnits/abcd'.
50   * @param AddTenantProjectRequest $postBody
51   * @param array $optParams Optional parameters.
52   * @return Operation
53   */
54  public function addProject($parent, AddTenantProjectRequest $postBody, $optParams = [])
55  {
56    $params = ['parent' => $parent, 'postBody' => $postBody];
57    $params = array_merge($params, $optParams);
58    return $this->call('addProject', [$params], Operation::class);
59  }
60  /**
61   * Apply a configuration to an existing tenant project. This project must exist
62   * in an active state and have the original owner account. The caller must have
63   * permission to add a project to the given tenancy unit. The configuration is
64   * applied, but any existing settings on the project aren't modified. Specified
65   * policy bindings are applied. Existing bindings aren't modified. Specified
66   * services are activated. No service is deactivated. If specified, new billing
67   * configuration is applied. Omit a billing configuration to keep the existing
68   * one. A service account in the project is created if previously non existed.
69   * Specified labels will be appended to tenant project, note that the value of
70   * existing label key will be updated if the same label key is requested. The
71   * specified folder is ignored, as moving a tenant project to a different folder
72   * isn't supported. The operation fails if any of the steps fail, but no
73   * rollback of already applied configuration changes is attempted. Operation.
74   * (tenancyUnits.applyProjectConfig)
75   *
76   * @param string $name Required. Name of the tenancy unit. Such as
77   * 'services/service.googleapis.com/projects/12345/tenancyUnits/abcd'.
78   * @param ApplyTenantProjectConfigRequest $postBody
79   * @param array $optParams Optional parameters.
80   * @return Operation
81   */
82  public function applyProjectConfig($name, ApplyTenantProjectConfigRequest $postBody, $optParams = [])
83  {
84    $params = ['name' => $name, 'postBody' => $postBody];
85    $params = array_merge($params, $optParams);
86    return $this->call('applyProjectConfig', [$params], Operation::class);
87  }
88  /**
89   * Attach an existing project to the tenancy unit as a new tenant resource. The
90   * project could either be the tenant project reserved by calling
91   * `AddTenantProject` under a tenancy unit of a service producer's project of a
92   * managed service, or from a separate project. The caller is checked against a
93   * set of permissions as if calling `AddTenantProject` on the same service
94   * consumer. To trigger the attachment, the targeted tenant project must be in a
95   * folder. Make sure the ServiceConsumerManagement service account is the owner
96   * of that project. These two requirements are already met if the project is
97   * reserved by calling `AddTenantProject`. Operation.
98   * (tenancyUnits.attachProject)
99   *
100   * @param string $name Required. Name of the tenancy unit that the project will
101   * be attached to. Such as
102   * 'services/service.googleapis.com/projects/12345/tenancyUnits/abcd'.
103   * @param AttachTenantProjectRequest $postBody
104   * @param array $optParams Optional parameters.
105   * @return Operation
106   */
107  public function attachProject($name, AttachTenantProjectRequest $postBody, $optParams = [])
108  {
109    $params = ['name' => $name, 'postBody' => $postBody];
110    $params = array_merge($params, $optParams);
111    return $this->call('attachProject', [$params], Operation::class);
112  }
113  /**
114   * Creates a tenancy unit with no tenant resources. If tenancy unit already
115   * exists, it will be returned, however, in this case, returned TenancyUnit does
116   * not have tenant_resources field set and ListTenancyUnits has to be used to
117   * get a complete TenancyUnit with all fields populated. (tenancyUnits.create)
118   *
119   * @param string $parent Required. services/{service}/{collection id}/{resource
120   * id} {collection id} is the cloud resource collection type representing the
121   * service consumer, for example 'projects', or 'organizations'. {resource id}
122   * is the consumer numeric id, such as project number: '123456'. {service} the
123   * name of a managed service, such as 'service.googleapis.com'. Enables service
124   * binding using the new tenancy unit.
125   * @param CreateTenancyUnitRequest $postBody
126   * @param array $optParams Optional parameters.
127   * @return TenancyUnit
128   */
129  public function create($parent, CreateTenancyUnitRequest $postBody, $optParams = [])
130  {
131    $params = ['parent' => $parent, 'postBody' => $postBody];
132    $params = array_merge($params, $optParams);
133    return $this->call('create', [$params], TenancyUnit::class);
134  }
135  /**
136   * Delete a tenancy unit. Before you delete the tenancy unit, there should be no
137   * tenant resources in it that aren't in a DELETED state. Operation.
138   * (tenancyUnits.delete)
139   *
140   * @param string $name Required. Name of the tenancy unit to be deleted.
141   * @param array $optParams Optional parameters.
142   * @return Operation
143   */
144  public function delete($name, $optParams = [])
145  {
146    $params = ['name' => $name];
147    $params = array_merge($params, $optParams);
148    return $this->call('delete', [$params], Operation::class);
149  }
150  /**
151   * Deletes the specified project resource identified by a tenant resource tag.
152   * The mothod removes a project lien with a 'TenantManager' origin if that was
153   * added. It will then attempt to delete the project. If that operation fails,
154   * this method also fails. After the project has been deleted, the tenant
155   * resource state is set to DELETED. To permanently remove resource metadata,
156   * call the `RemoveTenantProject` method. New resources with the same tag can't
157   * be added if there are existing resources in a DELETED state. Operation.
158   * (tenancyUnits.deleteProject)
159   *
160   * @param string $name Required. Name of the tenancy unit. Such as
161   * 'services/service.googleapis.com/projects/12345/tenancyUnits/abcd'.
162   * @param DeleteTenantProjectRequest $postBody
163   * @param array $optParams Optional parameters.
164   * @return Operation
165   */
166  public function deleteProject($name, DeleteTenantProjectRequest $postBody, $optParams = [])
167  {
168    $params = ['name' => $name, 'postBody' => $postBody];
169    $params = array_merge($params, $optParams);
170    return $this->call('deleteProject', [$params], Operation::class);
171  }
172  /**
173   * Find the tenancy unit for a managed service and service consumer. This method
174   * shouldn't be used in a service producer's runtime path, for example to find
175   * the tenant project number when creating VMs. Service producers must persist
176   * the tenant project's information after the project is created.
177   * (tenancyUnits.listServicesTenancyUnits)
178   *
179   * @param string $parent Required. Managed service and service consumer.
180   * Required. services/{service}/{collection id}/{resource id} {collection id} is
181   * the cloud resource collection type representing the service consumer, for
182   * example 'projects', or 'organizations'. {resource id} is the consumer numeric
183   * id, such as project number: '123456'. {service} the name of a service, such
184   * as 'service.googleapis.com'.
185   * @param array $optParams Optional parameters.
186   *
187   * @opt_param string filter Optional. Filter expression over tenancy resources
188   * field. Optional.
189   * @opt_param int pageSize Optional. The maximum number of results returned by
190   * this request.
191   * @opt_param string pageToken Optional. The continuation token, which is used
192   * to page through large result sets. To get the next page of results, set this
193   * parameter to the value of `nextPageToken` from the previous response.
194   * @return ListTenancyUnitsResponse
195   */
196  public function listServicesTenancyUnits($parent, $optParams = [])
197  {
198    $params = ['parent' => $parent];
199    $params = array_merge($params, $optParams);
200    return $this->call('list', [$params], ListTenancyUnitsResponse::class);
201  }
202  /**
203   * Removes the specified project resource identified by a tenant resource tag.
204   * The method removes the project lien with 'TenantManager' origin if that was
205   * added. It then attempts to delete the project. If that operation fails, this
206   * method also fails. Calls to remove already removed or non-existent tenant
207   * project succeed. After the project has been deleted, or if was already in a
208   * DELETED state, resource metadata is permanently removed from the tenancy
209   * unit. Operation. (tenancyUnits.removeProject)
210   *
211   * @param string $name Required. Name of the tenancy unit. Such as
212   * 'services/service.googleapis.com/projects/12345/tenancyUnits/abcd'.
213   * @param RemoveTenantProjectRequest $postBody
214   * @param array $optParams Optional parameters.
215   * @return Operation
216   */
217  public function removeProject($name, RemoveTenantProjectRequest $postBody, $optParams = [])
218  {
219    $params = ['name' => $name, 'postBody' => $postBody];
220    $params = array_merge($params, $optParams);
221    return $this->call('removeProject', [$params], Operation::class);
222  }
223  /**
224   * Attempts to undelete a previously deleted tenant project. The project must be
225   * in a DELETED state. There are no guarantees that an undeleted project will be
226   * in a fully restored and functional state. Call the `ApplyTenantProjectConfig`
227   * method to update its configuration and then validate all managed service
228   * resources. Operation. (tenancyUnits.undeleteProject)
229   *
230   * @param string $name Required. Name of the tenancy unit. Such as
231   * 'services/service.googleapis.com/projects/12345/tenancyUnits/abcd'.
232   * @param UndeleteTenantProjectRequest $postBody
233   * @param array $optParams Optional parameters.
234   * @return Operation
235   */
236  public function undeleteProject($name, UndeleteTenantProjectRequest $postBody, $optParams = [])
237  {
238    $params = ['name' => $name, 'postBody' => $postBody];
239    $params = array_merge($params, $optParams);
240    return $this->call('undeleteProject', [$params], Operation::class);
241  }
242}
243
244// Adding a class alias for backwards compatibility with the previous class name.
245class_alias(ServicesTenancyUnits::class, 'Google_Service_ServiceConsumerManagement_Resource_ServicesTenancyUnits');
246