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\FirebaseRules\Resource;
19
20use Google\Service\FirebaseRules\FirebaserulesEmpty;
21use Google\Service\FirebaseRules\ListRulesetsResponse;
22use Google\Service\FirebaseRules\Ruleset;
23
24/**
25 * The "rulesets" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $firebaserulesService = new Google\Service\FirebaseRules(...);
29 *   $rulesets = $firebaserulesService->rulesets;
30 *  </code>
31 */
32class ProjectsRulesets extends \Google\Service\Resource
33{
34  /**
35   * Create a `Ruleset` from `Source`. The `Ruleset` is given a unique generated
36   * name which is returned to the caller. `Source` containing syntactic or
37   * semantics errors will result in an error response indicating the first error
38   * encountered. For a detailed view of `Source` issues, use TestRuleset.
39   * (rulesets.create)
40   *
41   * @param string $name Required. Resource name for Project which owns this
42   * `Ruleset`. Format: `projects/{project_id}`
43   * @param Ruleset $postBody
44   * @param array $optParams Optional parameters.
45   * @return Ruleset
46   */
47  public function create($name, Ruleset $postBody, $optParams = [])
48  {
49    $params = ['name' => $name, 'postBody' => $postBody];
50    $params = array_merge($params, $optParams);
51    return $this->call('create', [$params], Ruleset::class);
52  }
53  /**
54   * Delete a `Ruleset` by resource name. If the `Ruleset` is referenced by a
55   * `Release` the operation will fail. (rulesets.delete)
56   *
57   * @param string $name Required. Resource name for the ruleset to delete.
58   * Format: `projects/{project_id}/rulesets/{ruleset_id}`
59   * @param array $optParams Optional parameters.
60   * @return FirebaserulesEmpty
61   */
62  public function delete($name, $optParams = [])
63  {
64    $params = ['name' => $name];
65    $params = array_merge($params, $optParams);
66    return $this->call('delete', [$params], FirebaserulesEmpty::class);
67  }
68  /**
69   * Get a `Ruleset` by name including the full `Source` contents. (rulesets.get)
70   *
71   * @param string $name Required. Resource name for the ruleset to get. Format:
72   * `projects/{project_id}/rulesets/{ruleset_id}`
73   * @param array $optParams Optional parameters.
74   * @return Ruleset
75   */
76  public function get($name, $optParams = [])
77  {
78    $params = ['name' => $name];
79    $params = array_merge($params, $optParams);
80    return $this->call('get', [$params], Ruleset::class);
81  }
82  /**
83   * List `Ruleset` metadata only and optionally filter the results by `Ruleset`
84   * name. The full `Source` contents of a `Ruleset` may be retrieved with
85   * GetRuleset. (rulesets.listProjectsRulesets)
86   *
87   * @param string $name Required. Resource name for the project. Format:
88   * `projects/{project_id}`
89   * @param array $optParams Optional parameters.
90   *
91   * @opt_param string filter `Ruleset` filter. The list method supports filters
92   * with restrictions on `Ruleset.name`. Filters on `Ruleset.create_time` should
93   * use the `date` function which parses strings that conform to the RFC 3339
94   * date/time specifications. Example: `create_time >
95   * date("2017-01-01T00:00:00Z") AND name=UUID-*`
96   * @opt_param int pageSize Page size to load. Maximum of 100. Defaults to 10.
97   * Note: `page_size` is just a hint and the service may choose to load less than
98   * `page_size` due to the size of the output. To traverse all of the releases,
99   * caller should iterate until the `page_token` is empty.
100   * @opt_param string pageToken Next page token for loading the next batch of
101   * `Ruleset` instances.
102   * @return ListRulesetsResponse
103   */
104  public function listProjectsRulesets($name, $optParams = [])
105  {
106    $params = ['name' => $name];
107    $params = array_merge($params, $optParams);
108    return $this->call('list', [$params], ListRulesetsResponse::class);
109  }
110}
111
112// Adding a class alias for backwards compatibility with the previous class name.
113class_alias(ProjectsRulesets::class, 'Google_Service_FirebaseRules_Resource_ProjectsRulesets');
114