Debian Codegraph @

policyanalyzer/v1/policyanalyzer-gen.go

raw
1 // Copyright 2026 Google LLC.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Code generated file. DO NOT EDIT.
6
7 // Package policyanalyzer provides access to the Policy Analyzer API.
8 //
9 // For product documentation, see: https://www.google.com
10 //
11 // # Library status
12 //
13 // These client libraries are officially supported by Google. However, this
14 // library is considered complete and is in maintenance mode. This means
15 // that we will address critical bugs and security issues but will not add
16 // any new features.
17 //
18 // When possible, we recommend using our newer
19 // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
20 // that are still actively being worked and iterated on.
21 //
22 // # Creating a client
23 //
24 // Usage example:
25 //
26 // import "google.golang.org/api/policyanalyzer/v1"
27 // ...
28 // ctx := context.Background()
29 // policyanalyzerService, err := policyanalyzer.NewService(ctx)
30 //
31 // In this example, Google Application Default Credentials are used for
32 // authentication. For information on how to create and obtain Application
33 // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
34 //
35 // # Other authentication options
36 //
37 // To use an API key for authentication (note: some APIs do not support API
38 // keys), use [google.golang.org/api/option.WithAPIKey]:
39 //
40 // policyanalyzerService, err := policyanalyzer.NewService(ctx, option.WithAPIKey("AIza..."))
41 //
42 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
43 // flow, use [google.golang.org/api/option.WithTokenSource]:
44 //
45 // config := &oauth2.Config{...}
46 // // ...
47 // token, err := config.Exchange(ctx, ...)
48 // policyanalyzerService, err := policyanalyzer.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
49 //
50 // See [google.golang.org/api/option.ClientOption] for details on options.
51 package policyanalyzer // import "google.golang.org/api/policyanalyzer/v1"
52
53 import (
54 "bytes"
55 "context"
56 "encoding/json"
57 "errors"
58 "fmt"
59 "io"
60 "log/slog"
61 "net/http"
62 "net/url"
63 "strconv"
64 "strings"
65
66 "github.com/googleapis/gax-go/v2/internallog"
67 googleapi "google.golang.org/api/googleapi"
68 internal "google.golang.org/api/internal"
69 gensupport "google.golang.org/api/internal/gensupport"
70 option "google.golang.org/api/option"
71 internaloption "google.golang.org/api/option/internaloption"
72 htransport "google.golang.org/api/transport/http"
73 )
74
75 // Always reference these packages, just in case the auto-generated code
76 // below doesn't.
77 var _ = bytes.NewBuffer
78 var _ = strconv.Itoa
79 var _ = fmt.Sprintf
80 var _ = json.NewDecoder
81 var _ = io.Copy
82 var _ = url.Parse
83 var _ = gensupport.MarshalJSON
84 var _ = googleapi.Version
85 var _ = errors.New
86 var _ = strings.Replace
87 var _ = context.Canceled
88 var _ = internaloption.WithDefaultEndpoint
89 var _ = internal.Version
90 var _ = internallog.New
91
92 const apiId = "policyanalyzer:v1"
93 const apiName = "policyanalyzer"
94 const apiVersion = "v1"
95 const basePath = "https://policyanalyzer.googleapis.com/"
96 const basePathTemplate = "https://policyanalyzer.UNIVERSE_DOMAIN/"
97 const mtlsBasePath = "https://policyanalyzer.mtls.googleapis.com/"
98
99 // OAuth2 scopes used by this API.
100 const (
101 // See, edit, configure, and delete your Google Cloud data and see the email
102 // address for your Google Account.
103 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
104 )
105
106 // NewService creates a new Service.
107 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
108 scopesOption := internaloption.WithDefaultScopes(
109 "https://www.googleapis.com/auth/cloud-platform",
110 )
111 // NOTE: prepend, so we don't override user-specified scopes.
112 opts = append([]option.ClientOption{scopesOption}, opts...)
113 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
114 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
115 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
116 opts = append(opts, internaloption.EnableNewAuthLibrary())
117 client, endpoint, err := htransport.NewClient(ctx, opts...)
118 if err != nil {
119 return nil, err
120 }
121 s := &Service{client: client, BasePath: basePath, logger: internaloption.GetLogger(opts)}
122 s.Folders = NewFoldersService(s)
123 s.Organizations = NewOrganizationsService(s)
124 s.Projects = NewProjectsService(s)
125 if endpoint != "" {
126 s.BasePath = endpoint
127 }
128 return s, nil
129 }
130
131 // New creates a new Service. It uses the provided http.Client for requests.
132 //
133 // Deprecated: please use NewService instead.
134 // To provide a custom HTTP client, use option.WithHTTPClient.
135 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
136 func New(client *http.Client) (*Service, error) {
137 if client == nil {
138 return nil, errors.New("client is nil")
139 }
140 return NewService(context.TODO(), option.WithHTTPClient(client))
141 }
142
143 type Service struct {
144 client *http.Client
145 logger *slog.Logger
146 BasePath string // API endpoint base URL
147 UserAgent string // optional additional User-Agent fragment
148
149 Folders *FoldersService
150
151 Organizations *OrganizationsService
152
153 Projects *ProjectsService
154 }
155
156 func (s *Service) userAgent() string {
157 if s.UserAgent == "" {
158 return googleapi.UserAgent
159 }
160 return googleapi.UserAgent + " " + s.UserAgent
161 }
162
163 func NewFoldersService(s *Service) *FoldersService {
164 rs := &FoldersService{s: s}
165 rs.Locations = NewFoldersLocationsService(s)
166 return rs
167 }
168
169 type FoldersService struct {
170 s *Service
171
172 Locations *FoldersLocationsService
173 }
174
175 func NewFoldersLocationsService(s *Service) *FoldersLocationsService {
176 rs := &FoldersLocationsService{s: s}
177 rs.ActivityTypes = NewFoldersLocationsActivityTypesService(s)
178 return rs
179 }
180
181 type FoldersLocationsService struct {
182 s *Service
183
184 ActivityTypes *FoldersLocationsActivityTypesService
185 }
186
187 func NewFoldersLocationsActivityTypesService(s *Service) *FoldersLocationsActivityTypesService {
188 rs := &FoldersLocationsActivityTypesService{s: s}
189 rs.Activities = NewFoldersLocationsActivityTypesActivitiesService(s)
190 return rs
191 }
192
193 type FoldersLocationsActivityTypesService struct {
194 s *Service
195
196 Activities *FoldersLocationsActivityTypesActivitiesService
197 }
198
199 func NewFoldersLocationsActivityTypesActivitiesService(s *Service) *FoldersLocationsActivityTypesActivitiesService {
200 rs := &FoldersLocationsActivityTypesActivitiesService{s: s}
201 return rs
202 }
203
204 type FoldersLocationsActivityTypesActivitiesService struct {
205 s *Service
206 }
207
208 func NewOrganizationsService(s *Service) *OrganizationsService {
209 rs := &OrganizationsService{s: s}
210 rs.Locations = NewOrganizationsLocationsService(s)
211 return rs
212 }
213
214 type OrganizationsService struct {
215 s *Service
216
217 Locations *OrganizationsLocationsService
218 }
219
220 func NewOrganizationsLocationsService(s *Service) *OrganizationsLocationsService {
221 rs := &OrganizationsLocationsService{s: s}
222 rs.ActivityTypes = NewOrganizationsLocationsActivityTypesService(s)
223 return rs
224 }
225
226 type OrganizationsLocationsService struct {
227 s *Service
228
229 ActivityTypes *OrganizationsLocationsActivityTypesService
230 }
231
232 func NewOrganizationsLocationsActivityTypesService(s *Service) *OrganizationsLocationsActivityTypesService {
233 rs := &OrganizationsLocationsActivityTypesService{s: s}
234 rs.Activities = NewOrganizationsLocationsActivityTypesActivitiesService(s)
235 return rs
236 }
237
238 type OrganizationsLocationsActivityTypesService struct {
239 s *Service
240
241 Activities *OrganizationsLocationsActivityTypesActivitiesService
242 }
243
244 func NewOrganizationsLocationsActivityTypesActivitiesService(s *Service) *OrganizationsLocationsActivityTypesActivitiesService {
245 rs := &OrganizationsLocationsActivityTypesActivitiesService{s: s}
246 return rs
247 }
248
249 type OrganizationsLocationsActivityTypesActivitiesService struct {
250 s *Service
251 }
252
253 func NewProjectsService(s *Service) *ProjectsService {
254 rs := &ProjectsService{s: s}
255 rs.Locations = NewProjectsLocationsService(s)
256 return rs
257 }
258
259 type ProjectsService struct {
260 s *Service
261
262 Locations *ProjectsLocationsService
263 }
264
265 func NewProjectsLocationsService(s *Service) *ProjectsLocationsService {
266 rs := &ProjectsLocationsService{s: s}
267 rs.ActivityTypes = NewProjectsLocationsActivityTypesService(s)
268 return rs
269 }
270
271 type ProjectsLocationsService struct {
272 s *Service
273
274 ActivityTypes *ProjectsLocationsActivityTypesService
275 }
276
277 func NewProjectsLocationsActivityTypesService(s *Service) *ProjectsLocationsActivityTypesService {
278 rs := &ProjectsLocationsActivityTypesService{s: s}
279 rs.Activities = NewProjectsLocationsActivityTypesActivitiesService(s)
280 return rs
281 }
282
283 type ProjectsLocationsActivityTypesService struct {
284 s *Service
285
286 Activities *ProjectsLocationsActivityTypesActivitiesService
287 }
288
289 func NewProjectsLocationsActivityTypesActivitiesService(s *Service) *ProjectsLocationsActivityTypesActivitiesService {
290 rs := &ProjectsLocationsActivityTypesActivitiesService{s: s}
291 return rs
292 }
293
294 type ProjectsLocationsActivityTypesActivitiesService struct {
295 s *Service
296 }
297
298 // GoogleCloudPolicyanalyzerV1Activity: Represents Activity on a GCP resource
299 // over specific observation period.
300 type GoogleCloudPolicyanalyzerV1Activity struct {
301 // Activity: A struct of custom fields to explain the activity.
302 Activity googleapi.RawMessage `json:"activity,omitempty"`
303 // ActivityType: The type of the activity.
304 ActivityType string `json:"activityType,omitempty"`
305 // FullResourceName: The full resource name that identifies the resource. For
306 // examples of full resource names for Google Cloud services, see
307 // https://cloud.google.com/iam/help/troubleshooter/full-resource-names.
308 FullResourceName string `json:"fullResourceName,omitempty"`
309 // ObservationPeriod: The data observation period to build the activity.
310 ObservationPeriod *GoogleCloudPolicyanalyzerV1ObservationPeriod `json:"observationPeriod,omitempty"`
311 // ForceSendFields is a list of field names (e.g. "Activity") to
312 // unconditionally include in API requests. By default, fields with empty or
313 // default values are omitted from API requests. See
314 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
315 // details.
316 ForceSendFields []string `json:"-"`
317 // NullFields is a list of field names (e.g. "Activity") to include in API
318 // requests with the JSON null value. By default, fields with empty values are
319 // omitted from API requests. See
320 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
321 NullFields []string `json:"-"`
322 }
323
324 func (s GoogleCloudPolicyanalyzerV1Activity) MarshalJSON() ([]byte, error) {
325 type NoMethod GoogleCloudPolicyanalyzerV1Activity
326 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
327 }
328
329 // GoogleCloudPolicyanalyzerV1ObservationPeriod: Represents data observation
330 // period.
331 type GoogleCloudPolicyanalyzerV1ObservationPeriod struct {
332 // EndTime: The observation end time. The time in this timestamp is always
333 // `07:00:00Z`.
334 EndTime string `json:"endTime,omitempty"`
335 // StartTime: The observation start time. The time in this timestamp is always
336 // `07:00:00Z`.
337 StartTime string `json:"startTime,omitempty"`
338 // ForceSendFields is a list of field names (e.g. "EndTime") to unconditionally
339 // include in API requests. By default, fields with empty or default values are
340 // omitted from API requests. See
341 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
342 // details.
343 ForceSendFields []string `json:"-"`
344 // NullFields is a list of field names (e.g. "EndTime") to include in API
345 // requests with the JSON null value. By default, fields with empty values are
346 // omitted from API requests. See
347 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
348 NullFields []string `json:"-"`
349 }
350
351 func (s GoogleCloudPolicyanalyzerV1ObservationPeriod) MarshalJSON() ([]byte, error) {
352 type NoMethod GoogleCloudPolicyanalyzerV1ObservationPeriod
353 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
354 }
355
356 // GoogleCloudPolicyanalyzerV1QueryActivityResponse: Response to the
357 // `QueryActivity` method.
358 type GoogleCloudPolicyanalyzerV1QueryActivityResponse struct {
359 // Activities: The set of activities that match the filter included in the
360 // request.
361 Activities []*GoogleCloudPolicyanalyzerV1Activity `json:"activities,omitempty"`
362 // NextPageToken: If there might be more results than those appearing in this
363 // response, then `nextPageToken` is included. To get the next set of results,
364 // call this method again using the value of `nextPageToken` as `pageToken`.
365 NextPageToken string `json:"nextPageToken,omitempty"`
366
367 // ServerResponse contains the HTTP response code and headers from the server.
368 googleapi.ServerResponse `json:"-"`
369 // ForceSendFields is a list of field names (e.g. "Activities") to
370 // unconditionally include in API requests. By default, fields with empty or
371 // default values are omitted from API requests. See
372 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
373 // details.
374 ForceSendFields []string `json:"-"`
375 // NullFields is a list of field names (e.g. "Activities") to include in API
376 // requests with the JSON null value. By default, fields with empty values are
377 // omitted from API requests. See
378 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
379 NullFields []string `json:"-"`
380 }
381
382 func (s GoogleCloudPolicyanalyzerV1QueryActivityResponse) MarshalJSON() ([]byte, error) {
383 type NoMethod GoogleCloudPolicyanalyzerV1QueryActivityResponse
384 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
385 }
386
387 type FoldersLocationsActivityTypesActivitiesQueryCall struct {
388 s *Service
389 parent string
390 urlParams_ gensupport.URLParams
391 ifNoneMatch_ string
392 ctx_ context.Context
393 header_ http.Header
394 }
395
396 // Query: Queries policy activities on Google Cloud resources.
397 //
398 // - parent: The container resource on which to execute the request. Acceptable
399 // formats:
400 // `projects/[PROJECT_ID|PROJECT_NUMBER]/locations/[LOCATION]/activityTypes/[A
401 // CTIVITY_TYPE]` LOCATION here refers to Google Cloud Locations:
402 // https://cloud.google.com/about/locations/.
403 func (r *FoldersLocationsActivityTypesActivitiesService) Query(parent string) *FoldersLocationsActivityTypesActivitiesQueryCall {
404 c := &FoldersLocationsActivityTypesActivitiesQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
405 c.parent = parent
406 return c
407 }
408
409 // Filter sets the optional parameter "filter": Filter expression to restrict
410 // the activities returned. For serviceAccountLastAuthentication activities,
411 // supported filters are: - `activities.full_resource_name {=} [STRING]` -
412 // `activities.fullResourceName {=} [STRING]` where `[STRING]` is the full
413 // resource name of the service account. For
414 // serviceAccountKeyLastAuthentication activities, supported filters are: -
415 // `activities.full_resource_name {=} [STRING]` - `activities.fullResourceName
416 // {=} [STRING]` where `[STRING]` is the full resource name of the service
417 // account key.
418 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) Filter(filter string) *FoldersLocationsActivityTypesActivitiesQueryCall {
419 c.urlParams_.Set("filter", filter)
420 return c
421 }
422
423 // PageSize sets the optional parameter "pageSize": The maximum number of
424 // results to return from this request. Max limit is 1000. Non-positive values
425 // are ignored. The presence of `nextPageToken` in the response indicates that
426 // more results might be available.
427 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) PageSize(pageSize int64) *FoldersLocationsActivityTypesActivitiesQueryCall {
428 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
429 return c
430 }
431
432 // PageToken sets the optional parameter "pageToken": If present, then retrieve
433 // the next batch of results from the preceding call to this method.
434 // `pageToken` must be the value of `nextPageToken` from the previous response.
435 // The values of other method parameters should be identical to those in the
436 // previous call.
437 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) PageToken(pageToken string) *FoldersLocationsActivityTypesActivitiesQueryCall {
438 c.urlParams_.Set("pageToken", pageToken)
439 return c
440 }
441
442 // Fields allows partial responses to be retrieved. See
443 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
444 // details.
445 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) Fields(s ...googleapi.Field) *FoldersLocationsActivityTypesActivitiesQueryCall {
446 c.urlParams_.Set("fields", googleapi.CombineFields(s))
447 return c
448 }
449
450 // IfNoneMatch sets an optional parameter which makes the operation fail if the
451 // object's ETag matches the given value. This is useful for getting updates
452 // only after the object has changed since the last request.
453 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) IfNoneMatch(entityTag string) *FoldersLocationsActivityTypesActivitiesQueryCall {
454 c.ifNoneMatch_ = entityTag
455 return c
456 }
457
458 // Context sets the context to be used in this call's Do method.
459 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) Context(ctx context.Context) *FoldersLocationsActivityTypesActivitiesQueryCall {
460 c.ctx_ = ctx
461 return c
462 }
463
464 // Header returns a http.Header that can be modified by the caller to add
465 // headers to the request.
466 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) Header() http.Header {
467 if c.header_ == nil {
468 c.header_ = make(http.Header)
469 }
470 return c.header_
471 }
472
473 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) doRequest(alt string) (*http.Response, error) {
474 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
475 if c.ifNoneMatch_ != "" {
476 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
477 }
478 c.urlParams_.Set("alt", alt)
479 c.urlParams_.Set("prettyPrint", "false")
480 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/activities:query")
481 urls += "?" + c.urlParams_.Encode()
482 req, err := http.NewRequest("GET", urls, nil)
483 if err != nil {
484 return nil, err
485 }
486 req.Header = reqHeaders
487 googleapi.Expand(req.URL, map[string]string{
488 "parent": c.parent,
489 })
490 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "policyanalyzer.folders.locations.activityTypes.activities.query", "request", internallog.HTTPRequest(req, nil))
491 return gensupport.SendRequest(c.ctx_, c.s.client, req)
492 }
493
494 // Do executes the "policyanalyzer.folders.locations.activityTypes.activities.query" call.
495 // Any non-2xx status code is an error. Response headers are in either
496 // *GoogleCloudPolicyanalyzerV1QueryActivityResponse.ServerResponse.Header or
497 // (if a response was returned at all) in error.(*googleapi.Error).Header. Use
498 // googleapi.IsNotModified to check whether the returned error was because
499 // http.StatusNotModified was returned.
500 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) Do(opts ...googleapi.CallOption) (*GoogleCloudPolicyanalyzerV1QueryActivityResponse, error) {
501 gensupport.SetOptions(c.urlParams_, opts...)
502 res, err := c.doRequest("json")
503 if res != nil && res.StatusCode == http.StatusNotModified {
504 if res.Body != nil {
505 res.Body.Close()
506 }
507 return nil, gensupport.WrapError(&googleapi.Error{
508 Code: res.StatusCode,
509 Header: res.Header,
510 })
511 }
512 if err != nil {
513 return nil, err
514 }
515 defer googleapi.CloseBody(res)
516 if err := googleapi.CheckResponse(res); err != nil {
517 return nil, gensupport.WrapError(err)
518 }
519 ret := &GoogleCloudPolicyanalyzerV1QueryActivityResponse{
520 ServerResponse: googleapi.ServerResponse{
521 Header: res.Header,
522 HTTPStatusCode: res.StatusCode,
523 },
524 }
525 target := &ret
526 b, err := gensupport.DecodeResponseBytes(target, res)
527 if err != nil {
528 return nil, err
529 }
530 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "policyanalyzer.folders.locations.activityTypes.activities.query", "response", internallog.HTTPResponse(res, b))
531 return ret, nil
532 }
533
534 // Pages invokes f for each page of results.
535 // A non-nil error returned from f will halt the iteration.
536 // The provided context supersedes any context provided to the Context method.
537 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) Pages(ctx context.Context, f func(*GoogleCloudPolicyanalyzerV1QueryActivityResponse) error) error {
538 c.ctx_ = ctx
539 defer c.PageToken(c.urlParams_.Get("pageToken"))
540 for {
541 x, err := c.Do()
542 if err != nil {
543 return err
544 }
545 if err := f(x); err != nil {
546 return err
547 }
548 if x.NextPageToken == "" {
549 return nil
550 }
551 c.PageToken(x.NextPageToken)
552 }
553 }
554
555 type OrganizationsLocationsActivityTypesActivitiesQueryCall struct {
556 s *Service
557 parent string
558 urlParams_ gensupport.URLParams
559 ifNoneMatch_ string
560 ctx_ context.Context
561 header_ http.Header
562 }
563
564 // Query: Queries policy activities on Google Cloud resources.
565 //
566 // - parent: The container resource on which to execute the request. Acceptable
567 // formats:
568 // `projects/[PROJECT_ID|PROJECT_NUMBER]/locations/[LOCATION]/activityTypes/[A
569 // CTIVITY_TYPE]` LOCATION here refers to Google Cloud Locations:
570 // https://cloud.google.com/about/locations/.
571 func (r *OrganizationsLocationsActivityTypesActivitiesService) Query(parent string) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
572 c := &OrganizationsLocationsActivityTypesActivitiesQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
573 c.parent = parent
574 return c
575 }
576
577 // Filter sets the optional parameter "filter": Filter expression to restrict
578 // the activities returned. For serviceAccountLastAuthentication activities,
579 // supported filters are: - `activities.full_resource_name {=} [STRING]` -
580 // `activities.fullResourceName {=} [STRING]` where `[STRING]` is the full
581 // resource name of the service account. For
582 // serviceAccountKeyLastAuthentication activities, supported filters are: -
583 // `activities.full_resource_name {=} [STRING]` - `activities.fullResourceName
584 // {=} [STRING]` where `[STRING]` is the full resource name of the service
585 // account key.
586 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) Filter(filter string) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
587 c.urlParams_.Set("filter", filter)
588 return c
589 }
590
591 // PageSize sets the optional parameter "pageSize": The maximum number of
592 // results to return from this request. Max limit is 1000. Non-positive values
593 // are ignored. The presence of `nextPageToken` in the response indicates that
594 // more results might be available.
595 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) PageSize(pageSize int64) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
596 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
597 return c
598 }
599
600 // PageToken sets the optional parameter "pageToken": If present, then retrieve
601 // the next batch of results from the preceding call to this method.
602 // `pageToken` must be the value of `nextPageToken` from the previous response.
603 // The values of other method parameters should be identical to those in the
604 // previous call.
605 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) PageToken(pageToken string) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
606 c.urlParams_.Set("pageToken", pageToken)
607 return c
608 }
609
610 // Fields allows partial responses to be retrieved. See
611 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
612 // details.
613 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) Fields(s ...googleapi.Field) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
614 c.urlParams_.Set("fields", googleapi.CombineFields(s))
615 return c
616 }
617
618 // IfNoneMatch sets an optional parameter which makes the operation fail if the
619 // object's ETag matches the given value. This is useful for getting updates
620 // only after the object has changed since the last request.
621 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) IfNoneMatch(entityTag string) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
622 c.ifNoneMatch_ = entityTag
623 return c
624 }
625
626 // Context sets the context to be used in this call's Do method.
627 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) Context(ctx context.Context) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
628 c.ctx_ = ctx
629 return c
630 }
631
632 // Header returns a http.Header that can be modified by the caller to add
633 // headers to the request.
634 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) Header() http.Header {
635 if c.header_ == nil {
636 c.header_ = make(http.Header)
637 }
638 return c.header_
639 }
640
641 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) doRequest(alt string) (*http.Response, error) {
642 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
643 if c.ifNoneMatch_ != "" {
644 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
645 }
646 c.urlParams_.Set("alt", alt)
647 c.urlParams_.Set("prettyPrint", "false")
648 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/activities:query")
649 urls += "?" + c.urlParams_.Encode()
650 req, err := http.NewRequest("GET", urls, nil)
651 if err != nil {
652 return nil, err
653 }
654 req.Header = reqHeaders
655 googleapi.Expand(req.URL, map[string]string{
656 "parent": c.parent,
657 })
658 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "policyanalyzer.organizations.locations.activityTypes.activities.query", "request", internallog.HTTPRequest(req, nil))
659 return gensupport.SendRequest(c.ctx_, c.s.client, req)
660 }
661
662 // Do executes the "policyanalyzer.organizations.locations.activityTypes.activities.query" call.
663 // Any non-2xx status code is an error. Response headers are in either
664 // *GoogleCloudPolicyanalyzerV1QueryActivityResponse.ServerResponse.Header or
665 // (if a response was returned at all) in error.(*googleapi.Error).Header. Use
666 // googleapi.IsNotModified to check whether the returned error was because
667 // http.StatusNotModified was returned.
668 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) Do(opts ...googleapi.CallOption) (*GoogleCloudPolicyanalyzerV1QueryActivityResponse, error) {
669 gensupport.SetOptions(c.urlParams_, opts...)
670 res, err := c.doRequest("json")
671 if res != nil && res.StatusCode == http.StatusNotModified {
672 if res.Body != nil {
673 res.Body.Close()
674 }
675 return nil, gensupport.WrapError(&googleapi.Error{
676 Code: res.StatusCode,
677 Header: res.Header,
678 })
679 }
680 if err != nil {
681 return nil, err
682 }
683 defer googleapi.CloseBody(res)
684 if err := googleapi.CheckResponse(res); err != nil {
685 return nil, gensupport.WrapError(err)
686 }
687 ret := &GoogleCloudPolicyanalyzerV1QueryActivityResponse{
688 ServerResponse: googleapi.ServerResponse{
689 Header: res.Header,
690 HTTPStatusCode: res.StatusCode,
691 },
692 }
693 target := &ret
694 b, err := gensupport.DecodeResponseBytes(target, res)
695 if err != nil {
696 return nil, err
697 }
698 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "policyanalyzer.organizations.locations.activityTypes.activities.query", "response", internallog.HTTPResponse(res, b))
699 return ret, nil
700 }
701
702 // Pages invokes f for each page of results.
703 // A non-nil error returned from f will halt the iteration.
704 // The provided context supersedes any context provided to the Context method.
705 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) Pages(ctx context.Context, f func(*GoogleCloudPolicyanalyzerV1QueryActivityResponse) error) error {
706 c.ctx_ = ctx
707 defer c.PageToken(c.urlParams_.Get("pageToken"))
708 for {
709 x, err := c.Do()
710 if err != nil {
711 return err
712 }
713 if err := f(x); err != nil {
714 return err
715 }
716 if x.NextPageToken == "" {
717 return nil
718 }
719 c.PageToken(x.NextPageToken)
720 }
721 }
722
723 type ProjectsLocationsActivityTypesActivitiesQueryCall struct {
724 s *Service
725 parent string
726 urlParams_ gensupport.URLParams
727 ifNoneMatch_ string
728 ctx_ context.Context
729 header_ http.Header
730 }
731
732 // Query: Queries policy activities on Google Cloud resources.
733 //
734 // - parent: The container resource on which to execute the request. Acceptable
735 // formats:
736 // `projects/[PROJECT_ID|PROJECT_NUMBER]/locations/[LOCATION]/activityTypes/[A
737 // CTIVITY_TYPE]` LOCATION here refers to Google Cloud Locations:
738 // https://cloud.google.com/about/locations/.
739 func (r *ProjectsLocationsActivityTypesActivitiesService) Query(parent string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
740 c := &ProjectsLocationsActivityTypesActivitiesQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
741 c.parent = parent
742 return c
743 }
744
745 // Filter sets the optional parameter "filter": Filter expression to restrict
746 // the activities returned. For serviceAccountLastAuthentication activities,
747 // supported filters are: - `activities.full_resource_name {=} [STRING]` -
748 // `activities.fullResourceName {=} [STRING]` where `[STRING]` is the full
749 // resource name of the service account. For
750 // serviceAccountKeyLastAuthentication activities, supported filters are: -
751 // `activities.full_resource_name {=} [STRING]` - `activities.fullResourceName
752 // {=} [STRING]` where `[STRING]` is the full resource name of the service
753 // account key.
754 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Filter(filter string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
755 c.urlParams_.Set("filter", filter)
756 return c
757 }
758
759 // PageSize sets the optional parameter "pageSize": The maximum number of
760 // results to return from this request. Max limit is 1000. Non-positive values
761 // are ignored. The presence of `nextPageToken` in the response indicates that
762 // more results might be available.
763 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) PageSize(pageSize int64) *ProjectsLocationsActivityTypesActivitiesQueryCall {
764 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
765 return c
766 }
767
768 // PageToken sets the optional parameter "pageToken": If present, then retrieve
769 // the next batch of results from the preceding call to this method.
770 // `pageToken` must be the value of `nextPageToken` from the previous response.
771 // The values of other method parameters should be identical to those in the
772 // previous call.
773 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) PageToken(pageToken string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
774 c.urlParams_.Set("pageToken", pageToken)
775 return c
776 }
777
778 // Fields allows partial responses to be retrieved. See
779 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
780 // details.
781 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Fields(s ...googleapi.Field) *ProjectsLocationsActivityTypesActivitiesQueryCall {
782 c.urlParams_.Set("fields", googleapi.CombineFields(s))
783 return c
784 }
785
786 // IfNoneMatch sets an optional parameter which makes the operation fail if the
787 // object's ETag matches the given value. This is useful for getting updates
788 // only after the object has changed since the last request.
789 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) IfNoneMatch(entityTag string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
790 c.ifNoneMatch_ = entityTag
791 return c
792 }
793
794 // Context sets the context to be used in this call's Do method.
795 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Context(ctx context.Context) *ProjectsLocationsActivityTypesActivitiesQueryCall {
796 c.ctx_ = ctx
797 return c
798 }
799
800 // Header returns a http.Header that can be modified by the caller to add
801 // headers to the request.
802 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Header() http.Header {
803 if c.header_ == nil {
804 c.header_ = make(http.Header)
805 }
806 return c.header_
807 }
808
809 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) doRequest(alt string) (*http.Response, error) {
810 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
811 if c.ifNoneMatch_ != "" {
812 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
813 }
814 c.urlParams_.Set("alt", alt)
815 c.urlParams_.Set("prettyPrint", "false")
816 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/activities:query")
817 urls += "?" + c.urlParams_.Encode()
818 req, err := http.NewRequest("GET", urls, nil)
819 if err != nil {
820 return nil, err
821 }
822 req.Header = reqHeaders
823 googleapi.Expand(req.URL, map[string]string{
824 "parent": c.parent,
825 })
826 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "policyanalyzer.projects.locations.activityTypes.activities.query", "request", internallog.HTTPRequest(req, nil))
827 return gensupport.SendRequest(c.ctx_, c.s.client, req)
828 }
829
830 // Do executes the "policyanalyzer.projects.locations.activityTypes.activities.query" call.
831 // Any non-2xx status code is an error. Response headers are in either
832 // *GoogleCloudPolicyanalyzerV1QueryActivityResponse.ServerResponse.Header or
833 // (if a response was returned at all) in error.(*googleapi.Error).Header. Use
834 // googleapi.IsNotModified to check whether the returned error was because
835 // http.StatusNotModified was returned.
836 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Do(opts ...googleapi.CallOption) (*GoogleCloudPolicyanalyzerV1QueryActivityResponse, error) {
837 gensupport.SetOptions(c.urlParams_, opts...)
838 res, err := c.doRequest("json")
839 if res != nil && res.StatusCode == http.StatusNotModified {
840 if res.Body != nil {
841 res.Body.Close()
842 }
843 return nil, gensupport.WrapError(&googleapi.Error{
844 Code: res.StatusCode,
845 Header: res.Header,
846 })
847 }
848 if err != nil {
849 return nil, err
850 }
851 defer googleapi.CloseBody(res)
852 if err := googleapi.CheckResponse(res); err != nil {
853 return nil, gensupport.WrapError(err)
854 }
855 ret := &GoogleCloudPolicyanalyzerV1QueryActivityResponse{
856 ServerResponse: googleapi.ServerResponse{
857 Header: res.Header,
858 HTTPStatusCode: res.StatusCode,
859 },
860 }
861 target := &ret
862 b, err := gensupport.DecodeResponseBytes(target, res)
863 if err != nil {
864 return nil, err
865 }
866 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "policyanalyzer.projects.locations.activityTypes.activities.query", "response", internallog.HTTPResponse(res, b))
867 return ret, nil
868 }
869
870 // Pages invokes f for each page of results.
871 // A non-nil error returned from f will halt the iteration.
872 // The provided context supersedes any context provided to the Context method.
873 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Pages(ctx context.Context, f func(*GoogleCloudPolicyanalyzerV1QueryActivityResponse) error) error {
874 c.ctx_ = ctx
875 defer c.PageToken(c.urlParams_.Get("pageToken"))
876 for {
877 x, err := c.Do()
878 if err != nil {
879 return err
880 }
881 if err := f(x); err != nil {
882 return err
883 }
884 if x.NextPageToken == "" {
885 return nil
886 }
887 c.PageToken(x.NextPageToken)
888 }
889 }