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\SecurityCommandCenter\Resource;
19
20use Google\Service\SecurityCommandCenter\Finding;
21use Google\Service\SecurityCommandCenter\GroupFindingsRequest;
22use Google\Service\SecurityCommandCenter\GroupFindingsResponse;
23use Google\Service\SecurityCommandCenter\ListFindingsResponse;
24use Google\Service\SecurityCommandCenter\SecurityMarks;
25use Google\Service\SecurityCommandCenter\SetFindingStateRequest;
26use Google\Service\SecurityCommandCenter\SetMuteRequest;
27
28/**
29 * The "findings" collection of methods.
30 * Typical usage is:
31 *  <code>
32 *   $securitycenterService = new Google\Service\SecurityCommandCenter(...);
33 *   $findings = $securitycenterService->findings;
34 *  </code>
35 */
36class ProjectsSourcesFindings extends \Google\Service\Resource
37{
38  /**
39   * Filters an organization or source's findings and groups them by their
40   * specified properties. To group across all sources provide a `-` as the source
41   * id. Example: /v1/organizations/{organization_id}/sources/-/findings,
42   * /v1/folders/{folder_id}/sources/-/findings,
43   * /v1/projects/{project_id}/sources/-/findings (findings.group)
44   *
45   * @param string $parent Required. Name of the source to groupBy. Its format is
46   * "organizations/[organization_id]/sources/[source_id]",
47   * folders/[folder_id]/sources/[source_id], or
48   * projects/[project_id]/sources/[source_id]. To groupBy across all sources
49   * provide a source_id of `-`. For example:
50   * organizations/{organization_id}/sources/-, folders/{folder_id}/sources/-, or
51   * projects/{project_id}/sources/-
52   * @param GroupFindingsRequest $postBody
53   * @param array $optParams Optional parameters.
54   * @return GroupFindingsResponse
55   */
56  public function group($parent, GroupFindingsRequest $postBody, $optParams = [])
57  {
58    $params = ['parent' => $parent, 'postBody' => $postBody];
59    $params = array_merge($params, $optParams);
60    return $this->call('group', [$params], GroupFindingsResponse::class);
61  }
62  /**
63   * Lists an organization or source's findings. To list across all sources
64   * provide a `-` as the source id. Example:
65   * /v1/organizations/{organization_id}/sources/-/findings
66   * (findings.listProjectsSourcesFindings)
67   *
68   * @param string $parent Required. Name of the source the findings belong to.
69   * Its format is "organizations/[organization_id]/sources/[source_id],
70   * folders/[folder_id]/sources/[source_id], or
71   * projects/[project_id]/sources/[source_id]". To list across all sources
72   * provide a source_id of `-`. For example:
73   * organizations/{organization_id}/sources/-, folders/{folder_id}/sources/- or
74   * projects/{projects_id}/sources/-
75   * @param array $optParams Optional parameters.
76   *
77   * @opt_param string compareDuration When compare_duration is set, the
78   * ListFindingsResult's "state_change" attribute is updated to indicate whether
79   * the finding had its state changed, the finding's state remained unchanged, or
80   * if the finding was added in any state during the compare_duration period of
81   * time that precedes the read_time. This is the time between (read_time -
82   * compare_duration) and read_time. The state_change value is derived based on
83   * the presence and state of the finding at the two points in time. Intermediate
84   * state changes between the two times don't affect the result. For example, the
85   * results aren't affected if the finding is made inactive and then active
86   * again. Possible "state_change" values when compare_duration is specified: *
87   * "CHANGED": indicates that the finding was present and matched the given
88   * filter at the start of compare_duration, but changed its state at read_time.
89   * * "UNCHANGED": indicates that the finding was present and matched the given
90   * filter at the start of compare_duration and did not change state at
91   * read_time. * "ADDED": indicates that the finding did not match the given
92   * filter or was not present at the start of compare_duration, but was present
93   * at read_time. * "REMOVED": indicates that the finding was present and matched
94   * the filter at the start of compare_duration, but did not match the filter at
95   * read_time. If compare_duration is not specified, then the only possible
96   * state_change is "UNUSED", which will be the state_change set for all findings
97   * present at read_time.
98   * @opt_param string fieldMask A field mask to specify the Finding fields to be
99   * listed in the response. An empty field mask will list all fields.
100   * @opt_param string filter Expression that defines the filter to apply across
101   * findings. The expression is a list of one or more restrictions combined via
102   * logical operators `AND` and `OR`. Parentheses are supported, and `OR` has
103   * higher precedence than `AND`. Restrictions have the form ` ` and may have a
104   * `-` character in front of them to indicate negation. Examples include: * name
105   * * source_properties.a_property * security_marks.marks.marka The supported
106   * operators are: * `=` for all value types. * `>`, `<`, `>=`, `<=` for integer
107   * values. * `:`, meaning substring matching, for strings. The supported value
108   * types are: * string literals in quotes. * integer literals without quotes. *
109   * boolean literals `true` and `false` without quotes. The following field and
110   * operator combinations are supported: * name: `=` * parent: `=`, `:` *
111   * resource_name: `=`, `:` * state: `=`, `:` * category: `=`, `:` *
112   * external_uri: `=`, `:` * event_time: `=`, `>`, `<`, `>=`, `<=` Usage: This
113   * should be milliseconds since epoch or an RFC3339 string. Examples:
114   * `event_time = "2019-06-10T16:07:18-07:00"` `event_time = 1560208038000` *
115   * severity: `=`, `:` * workflow_state: `=`, `:` * security_marks.marks: `=`,
116   * `:` * source_properties: `=`, `:`, `>`, `<`, `>=`, `<=` For example,
117   * `source_properties.size = 100` is a valid filter string. Use a partial match
118   * on the empty string to filter based on a property existing:
119   * `source_properties.my_property : ""` Use a negated partial match on the empty
120   * string to filter based on a property not existing:
121   * `-source_properties.my_property : ""` * resource: * resource.name: `=`, `:` *
122   * resource.parent_name: `=`, `:` * resource.parent_display_name: `=`, `:` *
123   * resource.project_name: `=`, `:` * resource.project_display_name: `=`, `:` *
124   * resource.type: `=`, `:` * resource.folders.resource_folder: `=`, `:` *
125   * resource.display_name: `=`, `:`
126   * @opt_param string orderBy Expression that defines what fields and order to
127   * use for sorting. The string value should follow SQL syntax: comma separated
128   * list of fields. For example: "name,resource_properties.a_property". The
129   * default sorting order is ascending. To specify descending order for a field,
130   * a suffix " desc" should be appended to the field name. For example: "name
131   * desc,source_properties.a_property". Redundant space characters in the syntax
132   * are insignificant. "name desc,source_properties.a_property" and " name desc ,
133   * source_properties.a_property " are equivalent. The following fields are
134   * supported: name parent state category resource_name event_time
135   * source_properties security_marks.marks
136   * @opt_param int pageSize The maximum number of results to return in a single
137   * response. Default is 10, minimum is 1, maximum is 1000.
138   * @opt_param string pageToken The value returned by the last
139   * `ListFindingsResponse`; indicates that this is a continuation of a prior
140   * `ListFindings` call, and that the system should return the next page of data.
141   * @opt_param string readTime Time used as a reference point when filtering
142   * findings. The filter is limited to findings existing at the supplied time and
143   * their values are those at that specific time. Absence of this field will
144   * default to the API's version of NOW.
145   * @return ListFindingsResponse
146   */
147  public function listProjectsSourcesFindings($parent, $optParams = [])
148  {
149    $params = ['parent' => $parent];
150    $params = array_merge($params, $optParams);
151    return $this->call('list', [$params], ListFindingsResponse::class);
152  }
153  /**
154   * Creates or updates a finding. The corresponding source must exist for a
155   * finding creation to succeed. (findings.patch)
156   *
157   * @param string $name The relative resource name of this finding. See:
158   * https://cloud.google.com/apis/design/resource_names#relative_resource_name
159   * Example:
160   * "organizations/{organization_id}/sources/{source_id}/findings/{finding_id}"
161   * @param Finding $postBody
162   * @param array $optParams Optional parameters.
163   *
164   * @opt_param string updateMask The FieldMask to use when updating the finding
165   * resource. This field should not be specified when creating a finding. When
166   * updating a finding, an empty mask is treated as updating all mutable fields
167   * and replacing source_properties. Individual source_properties can be
168   * added/updated by using "source_properties." in the field mask.
169   * @return Finding
170   */
171  public function patch($name, Finding $postBody, $optParams = [])
172  {
173    $params = ['name' => $name, 'postBody' => $postBody];
174    $params = array_merge($params, $optParams);
175    return $this->call('patch', [$params], Finding::class);
176  }
177  /**
178   * Updates the mute state of a finding. (findings.setMute)
179   *
180   * @param string $name Required. The relative resource name of the finding. See:
181   * https://cloud.google.com/apis/design/resource_names#relative_resource_name
182   * Example:
183   * "organizations/{organization_id}/sources/{source_id}/finding/{finding_id}",
184   * "folders/{folder_id}/sources/{source_id}/finding/{finding_id}",
185   * "projects/{project_id}/sources/{source_id}/finding/{finding_id}".
186   * @param SetMuteRequest $postBody
187   * @param array $optParams Optional parameters.
188   * @return Finding
189   */
190  public function setMute($name, SetMuteRequest $postBody, $optParams = [])
191  {
192    $params = ['name' => $name, 'postBody' => $postBody];
193    $params = array_merge($params, $optParams);
194    return $this->call('setMute', [$params], Finding::class);
195  }
196  /**
197   * Updates the state of a finding. (findings.setState)
198   *
199   * @param string $name Required. The relative resource name of the finding. See:
200   * https://cloud.google.com/apis/design/resource_names#relative_resource_name
201   * Example:
202   * "organizations/{organization_id}/sources/{source_id}/finding/{finding_id}".
203   * @param SetFindingStateRequest $postBody
204   * @param array $optParams Optional parameters.
205   * @return Finding
206   */
207  public function setState($name, SetFindingStateRequest $postBody, $optParams = [])
208  {
209    $params = ['name' => $name, 'postBody' => $postBody];
210    $params = array_merge($params, $optParams);
211    return $this->call('setState', [$params], Finding::class);
212  }
213  /**
214   * Updates security marks. (findings.updateSecurityMarks)
215   *
216   * @param string $name The relative resource name of the SecurityMarks. See:
217   * https://cloud.google.com/apis/design/resource_names#relative_resource_name
218   * Examples: "organizations/{organization_id}/assets/{asset_id}/securityMarks" "
219   * organizations/{organization_id}/sources/{source_id}/findings/{finding_id}/sec
220   * urityMarks".
221   * @param SecurityMarks $postBody
222   * @param array $optParams Optional parameters.
223   *
224   * @opt_param string startTime The time at which the updated SecurityMarks take
225   * effect. If not set uses current server time. Updates will be applied to the
226   * SecurityMarks that are active immediately preceding this time. Must be
227   * earlier or equal to the server time.
228   * @opt_param string updateMask The FieldMask to use when updating the security
229   * marks resource. The field mask must not contain duplicate fields. If empty or
230   * set to "marks", all marks will be replaced. Individual marks can be updated
231   * using "marks.".
232   * @return SecurityMarks
233   */
234  public function updateSecurityMarks($name, SecurityMarks $postBody, $optParams = [])
235  {
236    $params = ['name' => $name, 'postBody' => $postBody];
237    $params = array_merge($params, $optParams);
238    return $this->call('updateSecurityMarks', [$params], SecurityMarks::class);
239  }
240}
241
242// Adding a class alias for backwards compatibility with the previous class name.
243class_alias(ProjectsSourcesFindings::class, 'Google_Service_SecurityCommandCenter_Resource_ProjectsSourcesFindings');
244