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\ServiceDirectory\Resource;
19
20use Google\Service\ServiceDirectory\GetIamPolicyRequest;
21use Google\Service\ServiceDirectory\ListNamespacesResponse;
22use Google\Service\ServiceDirectory\Policy;
23use Google\Service\ServiceDirectory\ServicedirectoryEmpty;
24use Google\Service\ServiceDirectory\ServicedirectoryNamespace;
25use Google\Service\ServiceDirectory\SetIamPolicyRequest;
26use Google\Service\ServiceDirectory\TestIamPermissionsRequest;
27use Google\Service\ServiceDirectory\TestIamPermissionsResponse;
28
29/**
30 * The "namespaces" collection of methods.
31 * Typical usage is:
32 *  <code>
33 *   $servicedirectoryService = new Google\Service\ServiceDirectory(...);
34 *   $namespaces = $servicedirectoryService->namespaces;
35 *  </code>
36 */
37class ProjectsLocationsNamespaces extends \Google\Service\Resource
38{
39  /**
40   * Creates a namespace, and returns the new namespace. (namespaces.create)
41   *
42   * @param string $parent Required. The resource name of the project and location
43   * the namespace will be created in.
44   * @param ServicedirectoryNamespace $postBody
45   * @param array $optParams Optional parameters.
46   *
47   * @opt_param string namespaceId Required. The Resource ID must be 1-63
48   * characters long, and comply with RFC1035. Specifically, the name must be 1-63
49   * characters long and match the regular expression
50   * `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first character must be a
51   * lowercase letter, and all following characters must be a dash, lowercase
52   * letter, or digit, except the last character, which cannot be a dash.
53   * @return ServicedirectoryNamespace
54   */
55  public function create($parent, ServicedirectoryNamespace $postBody, $optParams = [])
56  {
57    $params = ['parent' => $parent, 'postBody' => $postBody];
58    $params = array_merge($params, $optParams);
59    return $this->call('create', [$params], ServicedirectoryNamespace::class);
60  }
61  /**
62   * Deletes a namespace. This also deletes all services and endpoints in the
63   * namespace. (namespaces.delete)
64   *
65   * @param string $name Required. The name of the namespace to delete.
66   * @param array $optParams Optional parameters.
67   * @return ServicedirectoryEmpty
68   */
69  public function delete($name, $optParams = [])
70  {
71    $params = ['name' => $name];
72    $params = array_merge($params, $optParams);
73    return $this->call('delete', [$params], ServicedirectoryEmpty::class);
74  }
75  /**
76   * Gets a namespace. (namespaces.get)
77   *
78   * @param string $name Required. The name of the namespace to retrieve.
79   * @param array $optParams Optional parameters.
80   * @return ServicedirectoryNamespace
81   */
82  public function get($name, $optParams = [])
83  {
84    $params = ['name' => $name];
85    $params = array_merge($params, $optParams);
86    return $this->call('get', [$params], ServicedirectoryNamespace::class);
87  }
88  /**
89   * Gets the IAM Policy for a resource (namespace or service only).
90   * (namespaces.getIamPolicy)
91   *
92   * @param string $resource REQUIRED: The resource for which the policy is being
93   * requested. See the operation documentation for the appropriate value for this
94   * field.
95   * @param GetIamPolicyRequest $postBody
96   * @param array $optParams Optional parameters.
97   * @return Policy
98   */
99  public function getIamPolicy($resource, GetIamPolicyRequest $postBody, $optParams = [])
100  {
101    $params = ['resource' => $resource, 'postBody' => $postBody];
102    $params = array_merge($params, $optParams);
103    return $this->call('getIamPolicy', [$params], Policy::class);
104  }
105  /**
106   * Lists all namespaces. (namespaces.listProjectsLocationsNamespaces)
107   *
108   * @param string $parent Required. The resource name of the project and location
109   * whose namespaces you'd like to list.
110   * @param array $optParams Optional parameters.
111   *
112   * @opt_param string filter Optional. The filter to list results by. General
113   * `filter` string syntax: ` ()` * `` can be `name` or `labels.` for map field *
114   * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` means `HAS`, and
115   * is roughly the same as `=` * `` must be the same data type as field * `` can
116   * be `AND`, `OR`, `NOT` Examples of valid filters: * `labels.owner` returns
117   * namespaces that have a label with the key `owner`, this is the same as
118   * `labels:owner` * `labels.owner=sd` returns namespaces that have key/value
119   * `owner=sd` * `name>projects/my-project/locations/us-
120   * east1/namespaces/namespace-c` returns namespaces that have name that is
121   * alphabetically later than the string, so "namespace-e" is returned but
122   * "namespace-a" is not * `labels.owner!=sd AND labels.foo=bar` returns
123   * namespaces that have `owner` in label key but value is not `sd` AND have
124   * key/value `foo=bar` * `doesnotexist.foo=bar` returns an empty list. Note that
125   * namespace doesn't have a field called "doesnotexist". Since the filter does
126   * not match any namespaces, it returns no results For more information about
127   * filtering, see [API Filtering](https://aip.dev/160).
128   * @opt_param string orderBy Optional. The order to list results by. General
129   * `order_by` string syntax: ` () (,)` * `` allows value: `name` * `` ascending
130   * or descending order by ``. If this is left blank, `asc` is used Note that an
131   * empty `order_by` string results in default order, which is order by `name` in
132   * ascending order.
133   * @opt_param int pageSize Optional. The maximum number of items to return.
134   * @opt_param string pageToken Optional. The next_page_token value returned from
135   * a previous List request, if any.
136   * @return ListNamespacesResponse
137   */
138  public function listProjectsLocationsNamespaces($parent, $optParams = [])
139  {
140    $params = ['parent' => $parent];
141    $params = array_merge($params, $optParams);
142    return $this->call('list', [$params], ListNamespacesResponse::class);
143  }
144  /**
145   * Updates a namespace. (namespaces.patch)
146   *
147   * @param string $name Immutable. The resource name for the namespace in the
148   * format `projects/locations/namespaces`.
149   * @param ServicedirectoryNamespace $postBody
150   * @param array $optParams Optional parameters.
151   *
152   * @opt_param string updateMask Required. List of fields to be updated in this
153   * request.
154   * @return ServicedirectoryNamespace
155   */
156  public function patch($name, ServicedirectoryNamespace $postBody, $optParams = [])
157  {
158    $params = ['name' => $name, 'postBody' => $postBody];
159    $params = array_merge($params, $optParams);
160    return $this->call('patch', [$params], ServicedirectoryNamespace::class);
161  }
162  /**
163   * Sets the IAM Policy for a resource (namespace or service only).
164   * (namespaces.setIamPolicy)
165   *
166   * @param string $resource REQUIRED: The resource for which the policy is being
167   * specified. See the operation documentation for the appropriate value for this
168   * field.
169   * @param SetIamPolicyRequest $postBody
170   * @param array $optParams Optional parameters.
171   * @return Policy
172   */
173  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
174  {
175    $params = ['resource' => $resource, 'postBody' => $postBody];
176    $params = array_merge($params, $optParams);
177    return $this->call('setIamPolicy', [$params], Policy::class);
178  }
179  /**
180   * Tests IAM permissions for a resource (namespace or service only).
181   * (namespaces.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(ProjectsLocationsNamespaces::class, 'Google_Service_ServiceDirectory_Resource_ProjectsLocationsNamespaces');
200