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