1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 package policyanalyzer
52
53 import (
54 "bytes"
55 "context"
56 "encoding/json"
57 "errors"
58 "fmt"
59 "io"
60 "net/http"
61 "net/url"
62 "strconv"
63 "strings"
64
65 googleapi "google.golang.org/api/googleapi"
66 internal "google.golang.org/api/internal"
67 gensupport "google.golang.org/api/internal/gensupport"
68 option "google.golang.org/api/option"
69 internaloption "google.golang.org/api/option/internaloption"
70 htransport "google.golang.org/api/transport/http"
71 )
72
73
74
75 var _ = bytes.NewBuffer
76 var _ = strconv.Itoa
77 var _ = fmt.Sprintf
78 var _ = json.NewDecoder
79 var _ = io.Copy
80 var _ = url.Parse
81 var _ = gensupport.MarshalJSON
82 var _ = googleapi.Version
83 var _ = errors.New
84 var _ = strings.Replace
85 var _ = context.Canceled
86 var _ = internaloption.WithDefaultEndpoint
87 var _ = internal.Version
88
89 const apiId = "policyanalyzer:v1"
90 const apiName = "policyanalyzer"
91 const apiVersion = "v1"
92 const basePath = "https://policyanalyzer.googleapis.com/"
93 const basePathTemplate = "https://policyanalyzer.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://policyanalyzer.mtls.googleapis.com/"
95
96
97 const (
98
99
100 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
101 )
102
103
104 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
105 scopesOption := internaloption.WithDefaultScopes(
106 "https://www.googleapis.com/auth/cloud-platform",
107 )
108
109 opts = append([]option.ClientOption{scopesOption}, opts...)
110 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
111 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
112 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
113 opts = append(opts, internaloption.EnableNewAuthLibrary())
114 client, endpoint, err := htransport.NewClient(ctx, opts...)
115 if err != nil {
116 return nil, err
117 }
118 s, err := New(client)
119 if err != nil {
120 return nil, err
121 }
122 if endpoint != "" {
123 s.BasePath = endpoint
124 }
125 return s, nil
126 }
127
128
129
130
131
132
133 func New(client *http.Client) (*Service, error) {
134 if client == nil {
135 return nil, errors.New("client is nil")
136 }
137 s := &Service{client: client, BasePath: basePath}
138 s.Projects = NewProjectsService(s)
139 return s, nil
140 }
141
142 type Service struct {
143 client *http.Client
144 BasePath string
145 UserAgent string
146
147 Projects *ProjectsService
148 }
149
150 func (s *Service) userAgent() string {
151 if s.UserAgent == "" {
152 return googleapi.UserAgent
153 }
154 return googleapi.UserAgent + " " + s.UserAgent
155 }
156
157 func NewProjectsService(s *Service) *ProjectsService {
158 rs := &ProjectsService{s: s}
159 rs.Locations = NewProjectsLocationsService(s)
160 return rs
161 }
162
163 type ProjectsService struct {
164 s *Service
165
166 Locations *ProjectsLocationsService
167 }
168
169 func NewProjectsLocationsService(s *Service) *ProjectsLocationsService {
170 rs := &ProjectsLocationsService{s: s}
171 rs.ActivityTypes = NewProjectsLocationsActivityTypesService(s)
172 return rs
173 }
174
175 type ProjectsLocationsService struct {
176 s *Service
177
178 ActivityTypes *ProjectsLocationsActivityTypesService
179 }
180
181 func NewProjectsLocationsActivityTypesService(s *Service) *ProjectsLocationsActivityTypesService {
182 rs := &ProjectsLocationsActivityTypesService{s: s}
183 rs.Activities = NewProjectsLocationsActivityTypesActivitiesService(s)
184 return rs
185 }
186
187 type ProjectsLocationsActivityTypesService struct {
188 s *Service
189
190 Activities *ProjectsLocationsActivityTypesActivitiesService
191 }
192
193 func NewProjectsLocationsActivityTypesActivitiesService(s *Service) *ProjectsLocationsActivityTypesActivitiesService {
194 rs := &ProjectsLocationsActivityTypesActivitiesService{s: s}
195 return rs
196 }
197
198 type ProjectsLocationsActivityTypesActivitiesService struct {
199 s *Service
200 }
201
202 type GoogleCloudPolicyanalyzerV1Activity struct {
203
204 Activity googleapi.RawMessage `json:"activity,omitempty"`
205
206 ActivityType string `json:"activityType,omitempty"`
207
208
209
210 FullResourceName string `json:"fullResourceName,omitempty"`
211
212 ObservationPeriod *GoogleCloudPolicyanalyzerV1ObservationPeriod `json:"observationPeriod,omitempty"`
213
214
215
216
217
218 ForceSendFields []string `json:"-"`
219
220
221
222
223 NullFields []string `json:"-"`
224 }
225
226 func (s *GoogleCloudPolicyanalyzerV1Activity) MarshalJSON() ([]byte, error) {
227 type NoMethod GoogleCloudPolicyanalyzerV1Activity
228 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
229 }
230
231
232
233 type GoogleCloudPolicyanalyzerV1ObservationPeriod struct {
234
235
236 EndTime string `json:"endTime,omitempty"`
237
238
239 StartTime string `json:"startTime,omitempty"`
240
241
242
243
244
245 ForceSendFields []string `json:"-"`
246
247
248
249
250 NullFields []string `json:"-"`
251 }
252
253 func (s *GoogleCloudPolicyanalyzerV1ObservationPeriod) MarshalJSON() ([]byte, error) {
254 type NoMethod GoogleCloudPolicyanalyzerV1ObservationPeriod
255 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
256 }
257
258
259
260 type GoogleCloudPolicyanalyzerV1QueryActivityResponse struct {
261
262
263 Activities []*GoogleCloudPolicyanalyzerV1Activity `json:"activities,omitempty"`
264
265
266
267 NextPageToken string `json:"nextPageToken,omitempty"`
268
269
270 googleapi.ServerResponse `json:"-"`
271
272
273
274
275
276 ForceSendFields []string `json:"-"`
277
278
279
280
281 NullFields []string `json:"-"`
282 }
283
284 func (s *GoogleCloudPolicyanalyzerV1QueryActivityResponse) MarshalJSON() ([]byte, error) {
285 type NoMethod GoogleCloudPolicyanalyzerV1QueryActivityResponse
286 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
287 }
288
289 type ProjectsLocationsActivityTypesActivitiesQueryCall struct {
290 s *Service
291 parent string
292 urlParams_ gensupport.URLParams
293 ifNoneMatch_ string
294 ctx_ context.Context
295 header_ http.Header
296 }
297
298
299
300
301
302
303
304
305 func (r *ProjectsLocationsActivityTypesActivitiesService) Query(parent string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
306 c := &ProjectsLocationsActivityTypesActivitiesQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
307 c.parent = parent
308 return c
309 }
310
311
312
313
314
315
316
317
318
319
320 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Filter(filter string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
321 c.urlParams_.Set("filter", filter)
322 return c
323 }
324
325
326
327
328
329 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) PageSize(pageSize int64) *ProjectsLocationsActivityTypesActivitiesQueryCall {
330 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
331 return c
332 }
333
334
335
336
337
338
339 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) PageToken(pageToken string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
340 c.urlParams_.Set("pageToken", pageToken)
341 return c
342 }
343
344
345
346
347 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Fields(s ...googleapi.Field) *ProjectsLocationsActivityTypesActivitiesQueryCall {
348 c.urlParams_.Set("fields", googleapi.CombineFields(s))
349 return c
350 }
351
352
353
354
355 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) IfNoneMatch(entityTag string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
356 c.ifNoneMatch_ = entityTag
357 return c
358 }
359
360
361 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Context(ctx context.Context) *ProjectsLocationsActivityTypesActivitiesQueryCall {
362 c.ctx_ = ctx
363 return c
364 }
365
366
367
368 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Header() http.Header {
369 if c.header_ == nil {
370 c.header_ = make(http.Header)
371 }
372 return c.header_
373 }
374
375 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) doRequest(alt string) (*http.Response, error) {
376 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
377 if c.ifNoneMatch_ != "" {
378 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
379 }
380 var body io.Reader = nil
381 c.urlParams_.Set("alt", alt)
382 c.urlParams_.Set("prettyPrint", "false")
383 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/activities:query")
384 urls += "?" + c.urlParams_.Encode()
385 req, err := http.NewRequest("GET", urls, body)
386 if err != nil {
387 return nil, err
388 }
389 req.Header = reqHeaders
390 googleapi.Expand(req.URL, map[string]string{
391 "parent": c.parent,
392 })
393 return gensupport.SendRequest(c.ctx_, c.s.client, req)
394 }
395
396
397
398
399
400
401
402 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Do(opts ...googleapi.CallOption) (*GoogleCloudPolicyanalyzerV1QueryActivityResponse, error) {
403 gensupport.SetOptions(c.urlParams_, opts...)
404 res, err := c.doRequest("json")
405 if res != nil && res.StatusCode == http.StatusNotModified {
406 if res.Body != nil {
407 res.Body.Close()
408 }
409 return nil, gensupport.WrapError(&googleapi.Error{
410 Code: res.StatusCode,
411 Header: res.Header,
412 })
413 }
414 if err != nil {
415 return nil, err
416 }
417 defer googleapi.CloseBody(res)
418 if err := googleapi.CheckResponse(res); err != nil {
419 return nil, gensupport.WrapError(err)
420 }
421 ret := &GoogleCloudPolicyanalyzerV1QueryActivityResponse{
422 ServerResponse: googleapi.ServerResponse{
423 Header: res.Header,
424 HTTPStatusCode: res.StatusCode,
425 },
426 }
427 target := &ret
428 if err := gensupport.DecodeResponse(target, res); err != nil {
429 return nil, err
430 }
431 return ret, nil
432 }
433
434
435
436
437 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Pages(ctx context.Context, f func(*GoogleCloudPolicyanalyzerV1QueryActivityResponse) error) error {
438 c.ctx_ = ctx
439 defer c.PageToken(c.urlParams_.Get("pageToken"))
440 for {
441 x, err := c.Do()
442 if err != nil {
443 return err
444 }
445 if err := f(x); err != nil {
446 return err
447 }
448 if x.NextPageToken == "" {
449 return nil
450 }
451 c.PageToken(x.NextPageToken)
452 }
453 }
454
View as plain text