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\CloudMachineLearningEngine\Resource;
19
20use Google\Service\CloudMachineLearningEngine\GoogleCloudMlV1ListModelsResponse;
21use Google\Service\CloudMachineLearningEngine\GoogleCloudMlV1Model;
22use Google\Service\CloudMachineLearningEngine\GoogleIamV1Policy;
23use Google\Service\CloudMachineLearningEngine\GoogleIamV1SetIamPolicyRequest;
24use Google\Service\CloudMachineLearningEngine\GoogleIamV1TestIamPermissionsRequest;
25use Google\Service\CloudMachineLearningEngine\GoogleIamV1TestIamPermissionsResponse;
26use Google\Service\CloudMachineLearningEngine\GoogleLongrunningOperation;
27
28/**
29 * The "models" collection of methods.
30 * Typical usage is:
31 *  <code>
32 *   $mlService = new Google\Service\CloudMachineLearningEngine(...);
33 *   $models = $mlService->models;
34 *  </code>
35 */
36class ProjectsModels extends \Google\Service\Resource
37{
38  /**
39   * Creates a model which will later contain one or more versions. You must add
40   * at least one version before you can request predictions from the model. Add
41   * versions by calling projects.models.versions.create. (models.create)
42   *
43   * @param string $parent Required. The project name.
44   * @param GoogleCloudMlV1Model $postBody
45   * @param array $optParams Optional parameters.
46   * @return GoogleCloudMlV1Model
47   */
48  public function create($parent, GoogleCloudMlV1Model $postBody, $optParams = [])
49  {
50    $params = ['parent' => $parent, 'postBody' => $postBody];
51    $params = array_merge($params, $optParams);
52    return $this->call('create', [$params], GoogleCloudMlV1Model::class);
53  }
54  /**
55   * Deletes a model. You can only delete a model if there are no versions in it.
56   * You can delete versions by calling projects.models.versions.delete.
57   * (models.delete)
58   *
59   * @param string $name Required. The name of the model.
60   * @param array $optParams Optional parameters.
61   * @return GoogleLongrunningOperation
62   */
63  public function delete($name, $optParams = [])
64  {
65    $params = ['name' => $name];
66    $params = array_merge($params, $optParams);
67    return $this->call('delete', [$params], GoogleLongrunningOperation::class);
68  }
69  /**
70   * Gets information about a model, including its name, the description (if set),
71   * and the default version (if at least one version of the model has been
72   * deployed). (models.get)
73   *
74   * @param string $name Required. The name of the model.
75   * @param array $optParams Optional parameters.
76   * @return GoogleCloudMlV1Model
77   */
78  public function get($name, $optParams = [])
79  {
80    $params = ['name' => $name];
81    $params = array_merge($params, $optParams);
82    return $this->call('get', [$params], GoogleCloudMlV1Model::class);
83  }
84  /**
85   * Gets the access control policy for a resource. Returns an empty policy if the
86   * resource exists and does not have a policy set. (models.getIamPolicy)
87   *
88   * @param string $resource REQUIRED: The resource for which the policy is being
89   * requested. See the operation documentation for the appropriate value for this
90   * field.
91   * @param array $optParams Optional parameters.
92   *
93   * @opt_param int options.requestedPolicyVersion Optional. The maximum policy
94   * version that will be used to format the policy. Valid values are 0, 1, and 3.
95   * Requests specifying an invalid value will be rejected. Requests for policies
96   * with any conditional role bindings must specify version 3. Policies with no
97   * conditional role bindings may specify any valid value or leave the field
98   * unset. The policy in the response might use the policy version that you
99   * specified, or it might use a lower policy version. For example, if you
100   * specify version 3, but the policy has no conditional role bindings, the
101   * response uses version 1. To learn which resources support conditions in their
102   * IAM policies, see the [IAM
103   * documentation](https://cloud.google.com/iam/help/conditions/resource-
104   * policies).
105   * @return GoogleIamV1Policy
106   */
107  public function getIamPolicy($resource, $optParams = [])
108  {
109    $params = ['resource' => $resource];
110    $params = array_merge($params, $optParams);
111    return $this->call('getIamPolicy', [$params], GoogleIamV1Policy::class);
112  }
113  /**
114   * Lists the models in a project. Each project can contain multiple models, and
115   * each model can have multiple versions. If there are no models that match the
116   * request parameters, the list request returns an empty response body: {}.
117   * (models.listProjectsModels)
118   *
119   * @param string $parent Required. The name of the project whose models are to
120   * be listed.
121   * @param array $optParams Optional parameters.
122   *
123   * @opt_param string filter Optional. Specifies the subset of models to
124   * retrieve.
125   * @opt_param int pageSize Optional. The number of models to retrieve per "page"
126   * of results. If there are more remaining results than this number, the
127   * response message will contain a valid value in the `next_page_token` field.
128   * The default value is 20, and the maximum page size is 100.
129   * @opt_param string pageToken Optional. A page token to request the next page
130   * of results. You get the token from the `next_page_token` field of the
131   * response from the previous call.
132   * @return GoogleCloudMlV1ListModelsResponse
133   */
134  public function listProjectsModels($parent, $optParams = [])
135  {
136    $params = ['parent' => $parent];
137    $params = array_merge($params, $optParams);
138    return $this->call('list', [$params], GoogleCloudMlV1ListModelsResponse::class);
139  }
140  /**
141   * Updates a specific model resource. Currently the only supported fields to
142   * update are `description` and `default_version.name`. (models.patch)
143   *
144   * @param string $name Required. The project name.
145   * @param GoogleCloudMlV1Model $postBody
146   * @param array $optParams Optional parameters.
147   *
148   * @opt_param string updateMask Required. Specifies the path, relative to
149   * `Model`, of the field to update. For example, to change the description of a
150   * model to "foo" and set its default version to "version_1", the `update_mask`
151   * parameter would be specified as `description`, `default_version.name`, and
152   * the `PATCH` request body would specify the new value, as follows: {
153   * "description": "foo", "defaultVersion": { "name":"version_1" } } Currently
154   * the supported update masks are `description` and `default_version.name`.
155   * @return GoogleLongrunningOperation
156   */
157  public function patch($name, GoogleCloudMlV1Model $postBody, $optParams = [])
158  {
159    $params = ['name' => $name, 'postBody' => $postBody];
160    $params = array_merge($params, $optParams);
161    return $this->call('patch', [$params], GoogleLongrunningOperation::class);
162  }
163  /**
164   * Sets the access control policy on the specified resource. Replaces any
165   * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
166   * `PERMISSION_DENIED` errors. (models.setIamPolicy)
167   *
168   * @param string $resource REQUIRED: The resource for which the policy is being
169   * specified. See the operation documentation for the appropriate value for this
170   * field.
171   * @param GoogleIamV1SetIamPolicyRequest $postBody
172   * @param array $optParams Optional parameters.
173   * @return GoogleIamV1Policy
174   */
175  public function setIamPolicy($resource, GoogleIamV1SetIamPolicyRequest $postBody, $optParams = [])
176  {
177    $params = ['resource' => $resource, 'postBody' => $postBody];
178    $params = array_merge($params, $optParams);
179    return $this->call('setIamPolicy', [$params], GoogleIamV1Policy::class);
180  }
181  /**
182   * Returns permissions that a caller has on the specified resource. If the
183   * resource does not exist, this will return an empty set of permissions, not a
184   * `NOT_FOUND` error. Note: This operation is designed to be used for building
185   * permission-aware UIs and command-line tools, not for authorization checking.
186   * This operation may "fail open" without warning. (models.testIamPermissions)
187   *
188   * @param string $resource REQUIRED: The resource for which the policy detail is
189   * being requested. See the operation documentation for the appropriate value
190   * for this field.
191   * @param GoogleIamV1TestIamPermissionsRequest $postBody
192   * @param array $optParams Optional parameters.
193   * @return GoogleIamV1TestIamPermissionsResponse
194   */
195  public function testIamPermissions($resource, GoogleIamV1TestIamPermissionsRequest $postBody, $optParams = [])
196  {
197    $params = ['resource' => $resource, 'postBody' => $postBody];
198    $params = array_merge($params, $optParams);
199    return $this->call('testIamPermissions', [$params], GoogleIamV1TestIamPermissionsResponse::class);
200  }
201}
202
203// Adding a class alias for backwards compatibility with the previous class name.
204class_alias(ProjectsModels::class, 'Google_Service_CloudMachineLearningEngine_Resource_ProjectsModels');
205