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\ContainerAnalysis\Resource;
19
20use Google\Service\ContainerAnalysis\BatchCreateOccurrencesRequest;
21use Google\Service\ContainerAnalysis\BatchCreateOccurrencesResponse;
22use Google\Service\ContainerAnalysis\ContaineranalysisEmpty;
23use Google\Service\ContainerAnalysis\GetIamPolicyRequest;
24use Google\Service\ContainerAnalysis\ListOccurrencesResponse;
25use Google\Service\ContainerAnalysis\Note;
26use Google\Service\ContainerAnalysis\Occurrence;
27use Google\Service\ContainerAnalysis\Policy;
28use Google\Service\ContainerAnalysis\SetIamPolicyRequest;
29use Google\Service\ContainerAnalysis\TestIamPermissionsRequest;
30use Google\Service\ContainerAnalysis\TestIamPermissionsResponse;
31use Google\Service\ContainerAnalysis\VulnerabilityOccurrencesSummary;
32
33/**
34 * The "occurrences" collection of methods.
35 * Typical usage is:
36 *  <code>
37 *   $containeranalysisService = new Google\Service\ContainerAnalysis(...);
38 *   $occurrences = $containeranalysisService->occurrences;
39 *  </code>
40 */
41class ProjectsOccurrences extends \Google\Service\Resource
42{
43  /**
44   * Creates new occurrences in batch. (occurrences.batchCreate)
45   *
46   * @param string $parent Required. The name of the project in the form of
47   * `projects/[PROJECT_ID]`, under which the occurrences are to be created.
48   * @param BatchCreateOccurrencesRequest $postBody
49   * @param array $optParams Optional parameters.
50   * @return BatchCreateOccurrencesResponse
51   */
52  public function batchCreate($parent, BatchCreateOccurrencesRequest $postBody, $optParams = [])
53  {
54    $params = ['parent' => $parent, 'postBody' => $postBody];
55    $params = array_merge($params, $optParams);
56    return $this->call('batchCreate', [$params], BatchCreateOccurrencesResponse::class);
57  }
58  /**
59   * Creates a new occurrence. (occurrences.create)
60   *
61   * @param string $parent Required. The name of the project in the form of
62   * `projects/[PROJECT_ID]`, under which the occurrence is to be created.
63   * @param Occurrence $postBody
64   * @param array $optParams Optional parameters.
65   * @return Occurrence
66   */
67  public function create($parent, Occurrence $postBody, $optParams = [])
68  {
69    $params = ['parent' => $parent, 'postBody' => $postBody];
70    $params = array_merge($params, $optParams);
71    return $this->call('create', [$params], Occurrence::class);
72  }
73  /**
74   * Deletes the specified occurrence. For example, use this method to delete an
75   * occurrence when the occurrence is no longer applicable for the given
76   * resource. (occurrences.delete)
77   *
78   * @param string $name Required. The name of the occurrence in the form of
79   * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
80   * @param array $optParams Optional parameters.
81   * @return ContaineranalysisEmpty
82   */
83  public function delete($name, $optParams = [])
84  {
85    $params = ['name' => $name];
86    $params = array_merge($params, $optParams);
87    return $this->call('delete', [$params], ContaineranalysisEmpty::class);
88  }
89  /**
90   * Gets the specified occurrence. (occurrences.get)
91   *
92   * @param string $name Required. The name of the occurrence in the form of
93   * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
94   * @param array $optParams Optional parameters.
95   * @return Occurrence
96   */
97  public function get($name, $optParams = [])
98  {
99    $params = ['name' => $name];
100    $params = array_merge($params, $optParams);
101    return $this->call('get', [$params], Occurrence::class);
102  }
103  /**
104   * Gets the access control policy for a note or an occurrence resource. Requires
105   * `containeranalysis.notes.setIamPolicy` or
106   * `containeranalysis.occurrences.setIamPolicy` permission if the resource is a
107   * note or occurrence, respectively. The resource takes the format
108   * `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
109   * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
110   * (occurrences.getIamPolicy)
111   *
112   * @param string $resource REQUIRED: The resource for which the policy is being
113   * requested. See the operation documentation for the appropriate value for this
114   * field.
115   * @param GetIamPolicyRequest $postBody
116   * @param array $optParams Optional parameters.
117   * @return Policy
118   */
119  public function getIamPolicy($resource, GetIamPolicyRequest $postBody, $optParams = [])
120  {
121    $params = ['resource' => $resource, 'postBody' => $postBody];
122    $params = array_merge($params, $optParams);
123    return $this->call('getIamPolicy', [$params], Policy::class);
124  }
125  /**
126   * Gets the note attached to the specified occurrence. Consumer projects can use
127   * this method to get a note that belongs to a provider project.
128   * (occurrences.getNotes)
129   *
130   * @param string $name Required. The name of the occurrence in the form of
131   * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
132   * @param array $optParams Optional parameters.
133   * @return Note
134   */
135  public function getNotes($name, $optParams = [])
136  {
137    $params = ['name' => $name];
138    $params = array_merge($params, $optParams);
139    return $this->call('getNotes', [$params], Note::class);
140  }
141  /**
142   * Gets a summary of the number and severity of occurrences.
143   * (occurrences.getVulnerabilitySummary)
144   *
145   * @param string $parent Required. The name of the project to get a
146   * vulnerability summary for in the form of `projects/[PROJECT_ID]`.
147   * @param array $optParams Optional parameters.
148   *
149   * @opt_param string filter The filter expression.
150   * @return VulnerabilityOccurrencesSummary
151   */
152  public function getVulnerabilitySummary($parent, $optParams = [])
153  {
154    $params = ['parent' => $parent];
155    $params = array_merge($params, $optParams);
156    return $this->call('getVulnerabilitySummary', [$params], VulnerabilityOccurrencesSummary::class);
157  }
158  /**
159   * Lists occurrences for the specified project.
160   * (occurrences.listProjectsOccurrences)
161   *
162   * @param string $parent Required. The name of the project to list occurrences
163   * for in the form of `projects/[PROJECT_ID]`.
164   * @param array $optParams Optional parameters.
165   *
166   * @opt_param string filter The filter expression.
167   * @opt_param int pageSize Number of occurrences to return in the list. Must be
168   * positive. Max allowed page size is 1000. If not specified, page size defaults
169   * to 20.
170   * @opt_param string pageToken Token to provide to skip to a particular spot in
171   * the list.
172   * @return ListOccurrencesResponse
173   */
174  public function listProjectsOccurrences($parent, $optParams = [])
175  {
176    $params = ['parent' => $parent];
177    $params = array_merge($params, $optParams);
178    return $this->call('list', [$params], ListOccurrencesResponse::class);
179  }
180  /**
181   * Updates the specified occurrence. (occurrences.patch)
182   *
183   * @param string $name Required. The name of the occurrence in the form of
184   * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
185   * @param Occurrence $postBody
186   * @param array $optParams Optional parameters.
187   *
188   * @opt_param string updateMask The fields to update.
189   * @return Occurrence
190   */
191  public function patch($name, Occurrence $postBody, $optParams = [])
192  {
193    $params = ['name' => $name, 'postBody' => $postBody];
194    $params = array_merge($params, $optParams);
195    return $this->call('patch', [$params], Occurrence::class);
196  }
197  /**
198   * Sets the access control policy on the specified note or occurrence. Requires
199   * `containeranalysis.notes.setIamPolicy` or
200   * `containeranalysis.occurrences.setIamPolicy` permission if the resource is a
201   * note or an occurrence, respectively. The resource takes the format
202   * `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
203   * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
204   * (occurrences.setIamPolicy)
205   *
206   * @param string $resource REQUIRED: The resource for which the policy is being
207   * specified. See the operation documentation for the appropriate value for this
208   * field.
209   * @param SetIamPolicyRequest $postBody
210   * @param array $optParams Optional parameters.
211   * @return Policy
212   */
213  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
214  {
215    $params = ['resource' => $resource, 'postBody' => $postBody];
216    $params = array_merge($params, $optParams);
217    return $this->call('setIamPolicy', [$params], Policy::class);
218  }
219  /**
220   * Returns the permissions that a caller has on the specified note or
221   * occurrence. Requires list permission on the project (for example,
222   * `containeranalysis.notes.list`). The resource takes the format
223   * `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and
224   * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
225   * (occurrences.testIamPermissions)
226   *
227   * @param string $resource REQUIRED: The resource for which the policy detail is
228   * being requested. See the operation documentation for the appropriate value
229   * for this field.
230   * @param TestIamPermissionsRequest $postBody
231   * @param array $optParams Optional parameters.
232   * @return TestIamPermissionsResponse
233   */
234  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
235  {
236    $params = ['resource' => $resource, 'postBody' => $postBody];
237    $params = array_merge($params, $optParams);
238    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
239  }
240}
241
242// Adding a class alias for backwards compatibility with the previous class name.
243class_alias(ProjectsOccurrences::class, 'Google_Service_ContainerAnalysis_Resource_ProjectsOccurrences');
244