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\ServiceUsage\Resource;
19
20use Google\Service\ServiceUsage\BatchEnableServicesRequest;
21use Google\Service\ServiceUsage\BatchGetServicesResponse;
22use Google\Service\ServiceUsage\DisableServiceRequest;
23use Google\Service\ServiceUsage\EnableServiceRequest;
24use Google\Service\ServiceUsage\GoogleApiServiceusageV1Service;
25use Google\Service\ServiceUsage\ListServicesResponse;
26use Google\Service\ServiceUsage\Operation;
27
28/**
29 * The "services" collection of methods.
30 * Typical usage is:
31 *  <code>
32 *   $serviceusageService = new Google\Service\ServiceUsage(...);
33 *   $services = $serviceusageService->services;
34 *  </code>
35 */
36class Services extends \Google\Service\Resource
37{
38  /**
39   * Enable multiple services on a project. The operation is atomic: if enabling
40   * any service fails, then the entire batch fails, and no state changes occur.
41   * To enable a single service, use the `EnableService` method instead.
42   * (services.batchEnable)
43   *
44   * @param string $parent Parent to enable services on. An example name would be:
45   * `projects/123` where `123` is the project number. The `BatchEnableServices`
46   * method currently only supports projects.
47   * @param BatchEnableServicesRequest $postBody
48   * @param array $optParams Optional parameters.
49   * @return Operation
50   */
51  public function batchEnable($parent, BatchEnableServicesRequest $postBody, $optParams = [])
52  {
53    $params = ['parent' => $parent, 'postBody' => $postBody];
54    $params = array_merge($params, $optParams);
55    return $this->call('batchEnable', [$params], Operation::class);
56  }
57  /**
58   * Returns the service configurations and enabled states for a given list of
59   * services. (services.batchGet)
60   *
61   * @param string $parent Parent to retrieve services from. If this is set, the
62   * parent of all of the services specified in `names` must match this field. An
63   * example name would be: `projects/123` where `123` is the project number. The
64   * `BatchGetServices` method currently only supports projects.
65   * @param array $optParams Optional parameters.
66   *
67   * @opt_param string names Names of the services to retrieve. An example name
68   * would be: `projects/123/services/serviceusage.googleapis.com` where `123` is
69   * the project number. A single request can get a maximum of 30 services at a
70   * time.
71   * @return BatchGetServicesResponse
72   */
73  public function batchGet($parent, $optParams = [])
74  {
75    $params = ['parent' => $parent];
76    $params = array_merge($params, $optParams);
77    return $this->call('batchGet', [$params], BatchGetServicesResponse::class);
78  }
79  /**
80   * Disable a service so that it can no longer be used with a project. This
81   * prevents unintended usage that may cause unexpected billing charges or
82   * security leaks. It is not valid to call the disable method on a service that
83   * is not currently enabled. Callers will receive a `FAILED_PRECONDITION` status
84   * if the target service is not currently enabled. (services.disable)
85   *
86   * @param string $name Name of the consumer and service to disable the service
87   * on. The enable and disable methods currently only support projects. An
88   * example name would be: `projects/123/services/serviceusage.googleapis.com`
89   * where `123` is the project number.
90   * @param DisableServiceRequest $postBody
91   * @param array $optParams Optional parameters.
92   * @return Operation
93   */
94  public function disable($name, DisableServiceRequest $postBody, $optParams = [])
95  {
96    $params = ['name' => $name, 'postBody' => $postBody];
97    $params = array_merge($params, $optParams);
98    return $this->call('disable', [$params], Operation::class);
99  }
100  /**
101   * Enable a service so that it can be used with a project. (services.enable)
102   *
103   * @param string $name Name of the consumer and service to enable the service
104   * on. The `EnableService` and `DisableService` methods currently only support
105   * projects. Enabling a service requires that the service is public or is shared
106   * with the user enabling the service. An example name would be:
107   * `projects/123/services/serviceusage.googleapis.com` where `123` is the
108   * project number.
109   * @param EnableServiceRequest $postBody
110   * @param array $optParams Optional parameters.
111   * @return Operation
112   */
113  public function enable($name, EnableServiceRequest $postBody, $optParams = [])
114  {
115    $params = ['name' => $name, 'postBody' => $postBody];
116    $params = array_merge($params, $optParams);
117    return $this->call('enable', [$params], Operation::class);
118  }
119  /**
120   * Returns the service configuration and enabled state for a given service.
121   * (services.get)
122   *
123   * @param string $name Name of the consumer and service to get the
124   * `ConsumerState` for. An example name would be:
125   * `projects/123/services/serviceusage.googleapis.com` where `123` is the
126   * project number.
127   * @param array $optParams Optional parameters.
128   * @return GoogleApiServiceusageV1Service
129   */
130  public function get($name, $optParams = [])
131  {
132    $params = ['name' => $name];
133    $params = array_merge($params, $optParams);
134    return $this->call('get', [$params], GoogleApiServiceusageV1Service::class);
135  }
136  /**
137   * List all services available to the specified project, and the current state
138   * of those services with respect to the project. The list includes all public
139   * services, all services for which the calling user has the
140   * `servicemanagement.services.bind` permission, and all services that have
141   * already been enabled on the project. The list can be filtered to only include
142   * services in a specific state, for example to only include services enabled on
143   * the project. WARNING: If you need to query enabled services frequently or
144   * across an organization, you should use [Cloud Asset Inventory
145   * API](https://cloud.google.com/asset-inventory/docs/apis), which provides
146   * higher throughput and richer filtering capability. (services.listServices)
147   *
148   * @param string $parent Parent to search for services on. An example name would
149   * be: `projects/123` where `123` is the project number.
150   * @param array $optParams Optional parameters.
151   *
152   * @opt_param string filter Only list services that conform to the given filter.
153   * The allowed filter strings are `state:ENABLED` and `state:DISABLED`.
154   * @opt_param int pageSize Requested size of the next page of data. Requested
155   * page size cannot exceed 200. If not set, the default page size is 50.
156   * @opt_param string pageToken Token identifying which result to start with,
157   * which is returned by a previous list call.
158   * @return ListServicesResponse
159   */
160  public function listServices($parent, $optParams = [])
161  {
162    $params = ['parent' => $parent];
163    $params = array_merge($params, $optParams);
164    return $this->call('list', [$params], ListServicesResponse::class);
165  }
166}
167
168// Adding a class alias for backwards compatibility with the previous class name.
169class_alias(Services::class, 'Google_Service_ServiceUsage_Resource_Services');
170