Debian Codegraph @

policyanalyzer/v1beta1/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/v1beta1"
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/v1beta1"
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:v1beta1"
93 const apiName = "policyanalyzer"
94 const apiVersion = "v1beta1"
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 // GoogleCloudPolicyanalyzerV1beta1Activity: Represents Activity on a GCP
299 // resource over specific observation period.
300 type GoogleCloudPolicyanalyzerV1beta1Activity 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 *GoogleCloudPolicyanalyzerV1beta1ObservationPeriod `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 GoogleCloudPolicyanalyzerV1beta1Activity) MarshalJSON() ([]byte, error) {
325 type NoMethod GoogleCloudPolicyanalyzerV1beta1Activity
326 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
327 }
328
329 // GoogleCloudPolicyanalyzerV1beta1ObservationPeriod: Represents data
330 // observation period.
331 type GoogleCloudPolicyanalyzerV1beta1ObservationPeriod struct {
332 // EndTime: The observation end time.
333 EndTime string `json:"endTime,omitempty"`
334 // StartTime: The observation start time.
335 StartTime string `json:"startTime,omitempty"`
336 // ForceSendFields is a list of field names (e.g. "EndTime") to unconditionally
337 // include in API requests. By default, fields with empty or default values are
338 // omitted from API requests. See
339 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
340 // details.
341 ForceSendFields []string `json:"-"`
342 // NullFields is a list of field names (e.g. "EndTime") to include in API
343 // requests with the JSON null value. By default, fields with empty values are
344 // omitted from API requests. See
345 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
346 NullFields []string `json:"-"`
347 }
348
349 func (s GoogleCloudPolicyanalyzerV1beta1ObservationPeriod) MarshalJSON() ([]byte, error) {
350 type NoMethod GoogleCloudPolicyanalyzerV1beta1ObservationPeriod
351 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
352 }
353
354 // GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse: Response to the
355 // `QueryActivity` method.
356 type GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse struct {
357 // Activities: The set of activities that match the filter included in the
358 // request.
359 Activities []*GoogleCloudPolicyanalyzerV1beta1Activity `json:"activities,omitempty"`
360 // NextPageToken: If there might be more results than those appearing in this
361 // response, then `nextPageToken` is included. To get the next set of results,
362 // call this method again using the value of `nextPageToken` as `pageToken`.
363 NextPageToken string `json:"nextPageToken,omitempty"`
364
365 // ServerResponse contains the HTTP response code and headers from the server.
366 googleapi.ServerResponse `json:"-"`
367 // ForceSendFields is a list of field names (e.g. "Activities") to
368 // unconditionally include in API requests. By default, fields with empty or
369 // default values are omitted from API requests. See
370 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
371 // details.
372 ForceSendFields []string `json:"-"`
373 // NullFields is a list of field names (e.g. "Activities") to include in API
374 // requests with the JSON null value. By default, fields with empty values are
375 // omitted from API requests. See
376 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
377 NullFields []string `json:"-"`
378 }
379
380 func (s GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse) MarshalJSON() ([]byte, error) {
381 type NoMethod GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse
382 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
383 }
384
385 type FoldersLocationsActivityTypesActivitiesQueryCall struct {
386 s *Service
387 parent string
388 urlParams_ gensupport.URLParams
389 ifNoneMatch_ string
390 ctx_ context.Context
391 header_ http.Header
392 }
393
394 // Query: Queries policy activities on GCP resources.
395 //
396 // - parent: The container resource on which to execute the request. Acceptable
397 // formats:
398 // `projects/[PROJECT_ID|PROJECT_NUMBER]/locations/[LOCATION]/activityTypes/[A
399 // CTIVITY_TYPE]` LOCATION here refers to GCP Locations:
400 // https://cloud.google.com/about/locations/.
401 func (r *FoldersLocationsActivityTypesActivitiesService) Query(parent string) *FoldersLocationsActivityTypesActivitiesQueryCall {
402 c := &FoldersLocationsActivityTypesActivitiesQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
403 c.parent = parent
404 return c
405 }
406
407 // Filter sets the optional parameter "filter": Optional filter expression to
408 // restrict the activities returned. Supported filters are: -
409 // service_account_last_authn.full_resource_name {=} -
410 // service_account_key_last_authn.full_resource_name {=}
411 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) Filter(filter string) *FoldersLocationsActivityTypesActivitiesQueryCall {
412 c.urlParams_.Set("filter", filter)
413 return c
414 }
415
416 // PageSize sets the optional parameter "pageSize": The maximum number of
417 // results to return from this request. Max limit is 1000. Non-positive values
418 // are ignored. The presence of `nextPageToken` in the response indicates that
419 // more results might be available.
420 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) PageSize(pageSize int64) *FoldersLocationsActivityTypesActivitiesQueryCall {
421 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
422 return c
423 }
424
425 // PageToken sets the optional parameter "pageToken": If present, then retrieve
426 // the next batch of results from the preceding call to this method.
427 // `pageToken` must be the value of `nextPageToken` from the previous response.
428 // The values of other method parameters should be identical to those in the
429 // previous call.
430 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) PageToken(pageToken string) *FoldersLocationsActivityTypesActivitiesQueryCall {
431 c.urlParams_.Set("pageToken", pageToken)
432 return c
433 }
434
435 // Fields allows partial responses to be retrieved. See
436 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
437 // details.
438 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) Fields(s ...googleapi.Field) *FoldersLocationsActivityTypesActivitiesQueryCall {
439 c.urlParams_.Set("fields", googleapi.CombineFields(s))
440 return c
441 }
442
443 // IfNoneMatch sets an optional parameter which makes the operation fail if the
444 // object's ETag matches the given value. This is useful for getting updates
445 // only after the object has changed since the last request.
446 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) IfNoneMatch(entityTag string) *FoldersLocationsActivityTypesActivitiesQueryCall {
447 c.ifNoneMatch_ = entityTag
448 return c
449 }
450
451 // Context sets the context to be used in this call's Do method.
452 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) Context(ctx context.Context) *FoldersLocationsActivityTypesActivitiesQueryCall {
453 c.ctx_ = ctx
454 return c
455 }
456
457 // Header returns a http.Header that can be modified by the caller to add
458 // headers to the request.
459 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) Header() http.Header {
460 if c.header_ == nil {
461 c.header_ = make(http.Header)
462 }
463 return c.header_
464 }
465
466 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) doRequest(alt string) (*http.Response, error) {
467 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
468 if c.ifNoneMatch_ != "" {
469 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
470 }
471 c.urlParams_.Set("alt", alt)
472 c.urlParams_.Set("prettyPrint", "false")
473 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+parent}/activities:query")
474 urls += "?" + c.urlParams_.Encode()
475 req, err := http.NewRequest("GET", urls, nil)
476 if err != nil {
477 return nil, err
478 }
479 req.Header = reqHeaders
480 googleapi.Expand(req.URL, map[string]string{
481 "parent": c.parent,
482 })
483 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "policyanalyzer.folders.locations.activityTypes.activities.query", "request", internallog.HTTPRequest(req, nil))
484 return gensupport.SendRequest(c.ctx_, c.s.client, req)
485 }
486
487 // Do executes the "policyanalyzer.folders.locations.activityTypes.activities.query" call.
488 // Any non-2xx status code is an error. Response headers are in either
489 // *GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse.ServerResponse.Header
490 // or (if a response was returned at all) in error.(*googleapi.Error).Header.
491 // Use googleapi.IsNotModified to check whether the returned error was because
492 // http.StatusNotModified was returned.
493 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) Do(opts ...googleapi.CallOption) (*GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse, error) {
494 gensupport.SetOptions(c.urlParams_, opts...)
495 res, err := c.doRequest("json")
496 if res != nil && res.StatusCode == http.StatusNotModified {
497 if res.Body != nil {
498 res.Body.Close()
499 }
500 return nil, gensupport.WrapError(&googleapi.Error{
501 Code: res.StatusCode,
502 Header: res.Header,
503 })
504 }
505 if err != nil {
506 return nil, err
507 }
508 defer googleapi.CloseBody(res)
509 if err := googleapi.CheckResponse(res); err != nil {
510 return nil, gensupport.WrapError(err)
511 }
512 ret := &GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse{
513 ServerResponse: googleapi.ServerResponse{
514 Header: res.Header,
515 HTTPStatusCode: res.StatusCode,
516 },
517 }
518 target := &ret
519 b, err := gensupport.DecodeResponseBytes(target, res)
520 if err != nil {
521 return nil, err
522 }
523 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "policyanalyzer.folders.locations.activityTypes.activities.query", "response", internallog.HTTPResponse(res, b))
524 return ret, nil
525 }
526
527 // Pages invokes f for each page of results.
528 // A non-nil error returned from f will halt the iteration.
529 // The provided context supersedes any context provided to the Context method.
530 func (c *FoldersLocationsActivityTypesActivitiesQueryCall) Pages(ctx context.Context, f func(*GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse) error) error {
531 c.ctx_ = ctx
532 defer c.PageToken(c.urlParams_.Get("pageToken"))
533 for {
534 x, err := c.Do()
535 if err != nil {
536 return err
537 }
538 if err := f(x); err != nil {
539 return err
540 }
541 if x.NextPageToken == "" {
542 return nil
543 }
544 c.PageToken(x.NextPageToken)
545 }
546 }
547
548 type OrganizationsLocationsActivityTypesActivitiesQueryCall struct {
549 s *Service
550 parent string
551 urlParams_ gensupport.URLParams
552 ifNoneMatch_ string
553 ctx_ context.Context
554 header_ http.Header
555 }
556
557 // Query: Queries policy activities on GCP resources.
558 //
559 // - parent: The container resource on which to execute the request. Acceptable
560 // formats:
561 // `projects/[PROJECT_ID|PROJECT_NUMBER]/locations/[LOCATION]/activityTypes/[A
562 // CTIVITY_TYPE]` LOCATION here refers to GCP Locations:
563 // https://cloud.google.com/about/locations/.
564 func (r *OrganizationsLocationsActivityTypesActivitiesService) Query(parent string) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
565 c := &OrganizationsLocationsActivityTypesActivitiesQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
566 c.parent = parent
567 return c
568 }
569
570 // Filter sets the optional parameter "filter": Optional filter expression to
571 // restrict the activities returned. Supported filters are: -
572 // service_account_last_authn.full_resource_name {=} -
573 // service_account_key_last_authn.full_resource_name {=}
574 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) Filter(filter string) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
575 c.urlParams_.Set("filter", filter)
576 return c
577 }
578
579 // PageSize sets the optional parameter "pageSize": The maximum number of
580 // results to return from this request. Max limit is 1000. Non-positive values
581 // are ignored. The presence of `nextPageToken` in the response indicates that
582 // more results might be available.
583 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) PageSize(pageSize int64) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
584 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
585 return c
586 }
587
588 // PageToken sets the optional parameter "pageToken": If present, then retrieve
589 // the next batch of results from the preceding call to this method.
590 // `pageToken` must be the value of `nextPageToken` from the previous response.
591 // The values of other method parameters should be identical to those in the
592 // previous call.
593 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) PageToken(pageToken string) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
594 c.urlParams_.Set("pageToken", pageToken)
595 return c
596 }
597
598 // Fields allows partial responses to be retrieved. See
599 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
600 // details.
601 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) Fields(s ...googleapi.Field) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
602 c.urlParams_.Set("fields", googleapi.CombineFields(s))
603 return c
604 }
605
606 // IfNoneMatch sets an optional parameter which makes the operation fail if the
607 // object's ETag matches the given value. This is useful for getting updates
608 // only after the object has changed since the last request.
609 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) IfNoneMatch(entityTag string) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
610 c.ifNoneMatch_ = entityTag
611 return c
612 }
613
614 // Context sets the context to be used in this call's Do method.
615 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) Context(ctx context.Context) *OrganizationsLocationsActivityTypesActivitiesQueryCall {
616 c.ctx_ = ctx
617 return c
618 }
619
620 // Header returns a http.Header that can be modified by the caller to add
621 // headers to the request.
622 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) Header() http.Header {
623 if c.header_ == nil {
624 c.header_ = make(http.Header)
625 }
626 return c.header_
627 }
628
629 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) doRequest(alt string) (*http.Response, error) {
630 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
631 if c.ifNoneMatch_ != "" {
632 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
633 }
634 c.urlParams_.Set("alt", alt)
635 c.urlParams_.Set("prettyPrint", "false")
636 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+parent}/activities:query")
637 urls += "?" + c.urlParams_.Encode()
638 req, err := http.NewRequest("GET", urls, nil)
639 if err != nil {
640 return nil, err
641 }
642 req.Header = reqHeaders
643 googleapi.Expand(req.URL, map[string]string{
644 "parent": c.parent,
645 })
646 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "policyanalyzer.organizations.locations.activityTypes.activities.query", "request", internallog.HTTPRequest(req, nil))
647 return gensupport.SendRequest(c.ctx_, c.s.client, req)
648 }
649
650 // Do executes the "policyanalyzer.organizations.locations.activityTypes.activities.query" call.
651 // Any non-2xx status code is an error. Response headers are in either
652 // *GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse.ServerResponse.Header
653 // or (if a response was returned at all) in error.(*googleapi.Error).Header.
654 // Use googleapi.IsNotModified to check whether the returned error was because
655 // http.StatusNotModified was returned.
656 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) Do(opts ...googleapi.CallOption) (*GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse, error) {
657 gensupport.SetOptions(c.urlParams_, opts...)
658 res, err := c.doRequest("json")
659 if res != nil && res.StatusCode == http.StatusNotModified {
660 if res.Body != nil {
661 res.Body.Close()
662 }
663 return nil, gensupport.WrapError(&googleapi.Error{
664 Code: res.StatusCode,
665 Header: res.Header,
666 })
667 }
668 if err != nil {
669 return nil, err
670 }
671 defer googleapi.CloseBody(res)
672 if err := googleapi.CheckResponse(res); err != nil {
673 return nil, gensupport.WrapError(err)
674 }
675 ret := &GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse{
676 ServerResponse: googleapi.ServerResponse{
677 Header: res.Header,
678 HTTPStatusCode: res.StatusCode,
679 },
680 }
681 target := &ret
682 b, err := gensupport.DecodeResponseBytes(target, res)
683 if err != nil {
684 return nil, err
685 }
686 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "policyanalyzer.organizations.locations.activityTypes.activities.query", "response", internallog.HTTPResponse(res, b))
687 return ret, nil
688 }
689
690 // Pages invokes f for each page of results.
691 // A non-nil error returned from f will halt the iteration.
692 // The provided context supersedes any context provided to the Context method.
693 func (c *OrganizationsLocationsActivityTypesActivitiesQueryCall) Pages(ctx context.Context, f func(*GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse) error) error {
694 c.ctx_ = ctx
695 defer c.PageToken(c.urlParams_.Get("pageToken"))
696 for {
697 x, err := c.Do()
698 if err != nil {
699 return err
700 }
701 if err := f(x); err != nil {
702 return err
703 }
704 if x.NextPageToken == "" {
705 return nil
706 }
707 c.PageToken(x.NextPageToken)
708 }
709 }
710
711 type ProjectsLocationsActivityTypesActivitiesQueryCall struct {
712 s *Service
713 parent string
714 urlParams_ gensupport.URLParams
715 ifNoneMatch_ string
716 ctx_ context.Context
717 header_ http.Header
718 }
719
720 // Query: Queries policy activities on GCP resources.
721 //
722 // - parent: The container resource on which to execute the request. Acceptable
723 // formats:
724 // `projects/[PROJECT_ID|PROJECT_NUMBER]/locations/[LOCATION]/activityTypes/[A
725 // CTIVITY_TYPE]` LOCATION here refers to GCP Locations:
726 // https://cloud.google.com/about/locations/.
727 func (r *ProjectsLocationsActivityTypesActivitiesService) Query(parent string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
728 c := &ProjectsLocationsActivityTypesActivitiesQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
729 c.parent = parent
730 return c
731 }
732
733 // Filter sets the optional parameter "filter": Optional filter expression to
734 // restrict the activities returned. Supported filters are: -
735 // service_account_last_authn.full_resource_name {=} -
736 // service_account_key_last_authn.full_resource_name {=}
737 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Filter(filter string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
738 c.urlParams_.Set("filter", filter)
739 return c
740 }
741
742 // PageSize sets the optional parameter "pageSize": The maximum number of
743 // results to return from this request. Max limit is 1000. Non-positive values
744 // are ignored. The presence of `nextPageToken` in the response indicates that
745 // more results might be available.
746 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) PageSize(pageSize int64) *ProjectsLocationsActivityTypesActivitiesQueryCall {
747 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
748 return c
749 }
750
751 // PageToken sets the optional parameter "pageToken": If present, then retrieve
752 // the next batch of results from the preceding call to this method.
753 // `pageToken` must be the value of `nextPageToken` from the previous response.
754 // The values of other method parameters should be identical to those in the
755 // previous call.
756 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) PageToken(pageToken string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
757 c.urlParams_.Set("pageToken", pageToken)
758 return c
759 }
760
761 // Fields allows partial responses to be retrieved. See
762 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
763 // details.
764 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Fields(s ...googleapi.Field) *ProjectsLocationsActivityTypesActivitiesQueryCall {
765 c.urlParams_.Set("fields", googleapi.CombineFields(s))
766 return c
767 }
768
769 // IfNoneMatch sets an optional parameter which makes the operation fail if the
770 // object's ETag matches the given value. This is useful for getting updates
771 // only after the object has changed since the last request.
772 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) IfNoneMatch(entityTag string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
773 c.ifNoneMatch_ = entityTag
774 return c
775 }
776
777 // Context sets the context to be used in this call's Do method.
778 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Context(ctx context.Context) *ProjectsLocationsActivityTypesActivitiesQueryCall {
779 c.ctx_ = ctx
780 return c
781 }
782
783 // Header returns a http.Header that can be modified by the caller to add
784 // headers to the request.
785 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Header() http.Header {
786 if c.header_ == nil {
787 c.header_ = make(http.Header)
788 }
789 return c.header_
790 }
791
792 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) doRequest(alt string) (*http.Response, error) {
793 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
794 if c.ifNoneMatch_ != "" {
795 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
796 }
797 c.urlParams_.Set("alt", alt)
798 c.urlParams_.Set("prettyPrint", "false")
799 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+parent}/activities:query")
800 urls += "?" + c.urlParams_.Encode()
801 req, err := http.NewRequest("GET", urls, nil)
802 if err != nil {
803 return nil, err
804 }
805 req.Header = reqHeaders
806 googleapi.Expand(req.URL, map[string]string{
807 "parent": c.parent,
808 })
809 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "policyanalyzer.projects.locations.activityTypes.activities.query", "request", internallog.HTTPRequest(req, nil))
810 return gensupport.SendRequest(c.ctx_, c.s.client, req)
811 }
812
813 // Do executes the "policyanalyzer.projects.locations.activityTypes.activities.query" call.
814 // Any non-2xx status code is an error. Response headers are in either
815 // *GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse.ServerResponse.Header
816 // or (if a response was returned at all) in error.(*googleapi.Error).Header.
817 // Use googleapi.IsNotModified to check whether the returned error was because
818 // http.StatusNotModified was returned.
819 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Do(opts ...googleapi.CallOption) (*GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse, error) {
820 gensupport.SetOptions(c.urlParams_, opts...)
821 res, err := c.doRequest("json")
822 if res != nil && res.StatusCode == http.StatusNotModified {
823 if res.Body != nil {
824 res.Body.Close()
825 }
826 return nil, gensupport.WrapError(&googleapi.Error{
827 Code: res.StatusCode,
828 Header: res.Header,
829 })
830 }
831 if err != nil {
832 return nil, err
833 }
834 defer googleapi.CloseBody(res)
835 if err := googleapi.CheckResponse(res); err != nil {
836 return nil, gensupport.WrapError(err)
837 }
838 ret := &GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse{
839 ServerResponse: googleapi.ServerResponse{
840 Header: res.Header,
841 HTTPStatusCode: res.StatusCode,
842 },
843 }
844 target := &ret
845 b, err := gensupport.DecodeResponseBytes(target, res)
846 if err != nil {
847 return nil, err
848 }
849 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "policyanalyzer.projects.locations.activityTypes.activities.query", "response", internallog.HTTPResponse(res, b))
850 return ret, nil
851 }
852
853 // Pages invokes f for each page of results.
854 // A non-nil error returned from f will halt the iteration.
855 // The provided context supersedes any context provided to the Context method.
856 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Pages(ctx context.Context, f func(*GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse) error) error {
857 c.ctx_ = ctx
858 defer c.PageToken(c.urlParams_.Get("pageToken"))
859 for {
860 x, err := c.Do()
861 if err != nil {
862 return err
863 }
864 if err := f(x); err != nil {
865 return err
866 }
867 if x.NextPageToken == "" {
868 return nil
869 }
870 c.PageToken(x.NextPageToken)
871 }
872 }