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\GoogleCloudMlV1ListVersionsResponse;
21use Google\Service\CloudMachineLearningEngine\GoogleCloudMlV1SetDefaultVersionRequest;
22use Google\Service\CloudMachineLearningEngine\GoogleCloudMlV1Version;
23use Google\Service\CloudMachineLearningEngine\GoogleLongrunningOperation;
24
25/**
26 * The "versions" collection of methods.
27 * Typical usage is:
28 *  <code>
29 *   $mlService = new Google\Service\CloudMachineLearningEngine(...);
30 *   $versions = $mlService->versions;
31 *  </code>
32 */
33class ProjectsModelsVersions extends \Google\Service\Resource
34{
35  /**
36   * Creates a new version of a model from a trained TensorFlow model. If the
37   * version created in the cloud by this call is the first deployed version of
38   * the specified model, it will be made the default version of the model. When
39   * you add a version to a model that already has one or more versions, the
40   * default version does not automatically change. If you want a new version to
41   * be the default, you must call projects.models.versions.setDefault.
42   * (versions.create)
43   *
44   * @param string $parent Required. The name of the model.
45   * @param GoogleCloudMlV1Version $postBody
46   * @param array $optParams Optional parameters.
47   * @return GoogleLongrunningOperation
48   */
49  public function create($parent, GoogleCloudMlV1Version $postBody, $optParams = [])
50  {
51    $params = ['parent' => $parent, 'postBody' => $postBody];
52    $params = array_merge($params, $optParams);
53    return $this->call('create', [$params], GoogleLongrunningOperation::class);
54  }
55  /**
56   * Deletes a model version. Each model can have multiple versions deployed and
57   * in use at any given time. Use this method to remove a single version. Note:
58   * You cannot delete the version that is set as the default version of the model
59   * unless it is the only remaining version. (versions.delete)
60   *
61   * @param string $name Required. The name of the version. You can get the names
62   * of all the versions of a model by calling projects.models.versions.list.
63   * @param array $optParams Optional parameters.
64   * @return GoogleLongrunningOperation
65   */
66  public function delete($name, $optParams = [])
67  {
68    $params = ['name' => $name];
69    $params = array_merge($params, $optParams);
70    return $this->call('delete', [$params], GoogleLongrunningOperation::class);
71  }
72  /**
73   * Gets information about a model version. Models can have multiple versions.
74   * You can call projects.models.versions.list to get the same information that
75   * this method returns for all of the versions of a model. (versions.get)
76   *
77   * @param string $name Required. The name of the version.
78   * @param array $optParams Optional parameters.
79   * @return GoogleCloudMlV1Version
80   */
81  public function get($name, $optParams = [])
82  {
83    $params = ['name' => $name];
84    $params = array_merge($params, $optParams);
85    return $this->call('get', [$params], GoogleCloudMlV1Version::class);
86  }
87  /**
88   * Gets basic information about all the versions of a model. If you expect that
89   * a model has many versions, or if you need to handle only a limited number of
90   * results at a time, you can request that the list be retrieved in batches
91   * (called pages). If there are no versions that match the request parameters,
92   * the list request returns an empty response body: {}.
93   * (versions.listProjectsModelsVersions)
94   *
95   * @param string $parent Required. The name of the model for which to list the
96   * version.
97   * @param array $optParams Optional parameters.
98   *
99   * @opt_param string filter Optional. Specifies the subset of versions to
100   * retrieve.
101   * @opt_param int pageSize Optional. The number of versions to retrieve per
102   * "page" of results. If there are more remaining results than this number, the
103   * response message will contain a valid value in the `next_page_token` field.
104   * The default value is 20, and the maximum page size is 100.
105   * @opt_param string pageToken Optional. A page token to request the next page
106   * of results. You get the token from the `next_page_token` field of the
107   * response from the previous call.
108   * @return GoogleCloudMlV1ListVersionsResponse
109   */
110  public function listProjectsModelsVersions($parent, $optParams = [])
111  {
112    $params = ['parent' => $parent];
113    $params = array_merge($params, $optParams);
114    return $this->call('list', [$params], GoogleCloudMlV1ListVersionsResponse::class);
115  }
116  /**
117   * Updates the specified Version resource. Currently the only update-able fields
118   * are `description`, `requestLoggingConfig`, `autoScaling.minNodes`, and
119   * `manualScaling.nodes`. (versions.patch)
120   *
121   * @param string $name Required. The name of the model.
122   * @param GoogleCloudMlV1Version $postBody
123   * @param array $optParams Optional parameters.
124   *
125   * @opt_param string updateMask Required. Specifies the path, relative to
126   * `Version`, of the field to update. Must be present and non-empty. For
127   * example, to change the description of a version to "foo", the `update_mask`
128   * parameter would be specified as `description`, and the `PATCH` request body
129   * would specify the new value, as follows: ``` { "description": "foo" } ```
130   * Currently the only supported update mask fields are `description`,
131   * `requestLoggingConfig`, `autoScaling.minNodes`, and `manualScaling.nodes`.
132   * However, you can only update `manualScaling.nodes` if the version uses a
133   * [Compute Engine (N1) machine type](/ml-engine/docs/machine-types-online-
134   * prediction).
135   * @return GoogleLongrunningOperation
136   */
137  public function patch($name, GoogleCloudMlV1Version $postBody, $optParams = [])
138  {
139    $params = ['name' => $name, 'postBody' => $postBody];
140    $params = array_merge($params, $optParams);
141    return $this->call('patch', [$params], GoogleLongrunningOperation::class);
142  }
143  /**
144   * Designates a version to be the default for the model. The default version is
145   * used for prediction requests made against the model that don't specify a
146   * version. The first version to be created for a model is automatically set as
147   * the default. You must make any subsequent changes to the default version
148   * setting manually using this method. (versions.setDefault)
149   *
150   * @param string $name Required. The name of the version to make the default for
151   * the model. You can get the names of all the versions of a model by calling
152   * projects.models.versions.list.
153   * @param GoogleCloudMlV1SetDefaultVersionRequest $postBody
154   * @param array $optParams Optional parameters.
155   * @return GoogleCloudMlV1Version
156   */
157  public function setDefault($name, GoogleCloudMlV1SetDefaultVersionRequest $postBody, $optParams = [])
158  {
159    $params = ['name' => $name, 'postBody' => $postBody];
160    $params = array_merge($params, $optParams);
161    return $this->call('setDefault', [$params], GoogleCloudMlV1Version::class);
162  }
163}
164
165// Adding a class alias for backwards compatibility with the previous class name.
166class_alias(ProjectsModelsVersions::class, 'Google_Service_CloudMachineLearningEngine_Resource_ProjectsModelsVersions');
167