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:v1beta1"
90 const apiName = "policyanalyzer"
91 const apiVersion = "v1beta1"
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 GoogleCloudPolicyanalyzerV1beta1Activity 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 *GoogleCloudPolicyanalyzerV1beta1ObservationPeriod `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 *GoogleCloudPolicyanalyzerV1beta1Activity) MarshalJSON() ([]byte, error) {
227 type NoMethod GoogleCloudPolicyanalyzerV1beta1Activity
228 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
229 }
230
231
232
233 type GoogleCloudPolicyanalyzerV1beta1ObservationPeriod struct {
234
235 EndTime string `json:"endTime,omitempty"`
236
237 StartTime string `json:"startTime,omitempty"`
238
239
240
241
242
243 ForceSendFields []string `json:"-"`
244
245
246
247
248 NullFields []string `json:"-"`
249 }
250
251 func (s *GoogleCloudPolicyanalyzerV1beta1ObservationPeriod) MarshalJSON() ([]byte, error) {
252 type NoMethod GoogleCloudPolicyanalyzerV1beta1ObservationPeriod
253 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
254 }
255
256
257
258 type GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse struct {
259
260
261 Activities []*GoogleCloudPolicyanalyzerV1beta1Activity `json:"activities,omitempty"`
262
263
264
265 NextPageToken string `json:"nextPageToken,omitempty"`
266
267
268 googleapi.ServerResponse `json:"-"`
269
270
271
272
273
274 ForceSendFields []string `json:"-"`
275
276
277
278
279 NullFields []string `json:"-"`
280 }
281
282 func (s *GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse) MarshalJSON() ([]byte, error) {
283 type NoMethod GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse
284 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
285 }
286
287 type ProjectsLocationsActivityTypesActivitiesQueryCall struct {
288 s *Service
289 parent string
290 urlParams_ gensupport.URLParams
291 ifNoneMatch_ string
292 ctx_ context.Context
293 header_ http.Header
294 }
295
296
297
298
299
300
301
302
303 func (r *ProjectsLocationsActivityTypesActivitiesService) Query(parent string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
304 c := &ProjectsLocationsActivityTypesActivitiesQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
305 c.parent = parent
306 return c
307 }
308
309
310
311
312
313 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Filter(filter string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
314 c.urlParams_.Set("filter", filter)
315 return c
316 }
317
318
319
320
321
322 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) PageSize(pageSize int64) *ProjectsLocationsActivityTypesActivitiesQueryCall {
323 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
324 return c
325 }
326
327
328
329
330
331
332 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) PageToken(pageToken string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
333 c.urlParams_.Set("pageToken", pageToken)
334 return c
335 }
336
337
338
339
340 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Fields(s ...googleapi.Field) *ProjectsLocationsActivityTypesActivitiesQueryCall {
341 c.urlParams_.Set("fields", googleapi.CombineFields(s))
342 return c
343 }
344
345
346
347
348 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) IfNoneMatch(entityTag string) *ProjectsLocationsActivityTypesActivitiesQueryCall {
349 c.ifNoneMatch_ = entityTag
350 return c
351 }
352
353
354 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Context(ctx context.Context) *ProjectsLocationsActivityTypesActivitiesQueryCall {
355 c.ctx_ = ctx
356 return c
357 }
358
359
360
361 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Header() http.Header {
362 if c.header_ == nil {
363 c.header_ = make(http.Header)
364 }
365 return c.header_
366 }
367
368 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) doRequest(alt string) (*http.Response, error) {
369 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
370 if c.ifNoneMatch_ != "" {
371 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
372 }
373 var body io.Reader = nil
374 c.urlParams_.Set("alt", alt)
375 c.urlParams_.Set("prettyPrint", "false")
376 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+parent}/activities:query")
377 urls += "?" + c.urlParams_.Encode()
378 req, err := http.NewRequest("GET", urls, body)
379 if err != nil {
380 return nil, err
381 }
382 req.Header = reqHeaders
383 googleapi.Expand(req.URL, map[string]string{
384 "parent": c.parent,
385 })
386 return gensupport.SendRequest(c.ctx_, c.s.client, req)
387 }
388
389
390
391
392
393
394
395 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Do(opts ...googleapi.CallOption) (*GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse, error) {
396 gensupport.SetOptions(c.urlParams_, opts...)
397 res, err := c.doRequest("json")
398 if res != nil && res.StatusCode == http.StatusNotModified {
399 if res.Body != nil {
400 res.Body.Close()
401 }
402 return nil, gensupport.WrapError(&googleapi.Error{
403 Code: res.StatusCode,
404 Header: res.Header,
405 })
406 }
407 if err != nil {
408 return nil, err
409 }
410 defer googleapi.CloseBody(res)
411 if err := googleapi.CheckResponse(res); err != nil {
412 return nil, gensupport.WrapError(err)
413 }
414 ret := &GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse{
415 ServerResponse: googleapi.ServerResponse{
416 Header: res.Header,
417 HTTPStatusCode: res.StatusCode,
418 },
419 }
420 target := &ret
421 if err := gensupport.DecodeResponse(target, res); err != nil {
422 return nil, err
423 }
424 return ret, nil
425 }
426
427
428
429
430 func (c *ProjectsLocationsActivityTypesActivitiesQueryCall) Pages(ctx context.Context, f func(*GoogleCloudPolicyanalyzerV1beta1QueryActivityResponse) error) error {
431 c.ctx_ = ctx
432 defer c.PageToken(c.urlParams_.Get("pageToken"))
433 for {
434 x, err := c.Do()
435 if err != nil {
436 return err
437 }
438 if err := f(x); err != nil {
439 return err
440 }
441 if x.NextPageToken == "" {
442 return nil
443 }
444 c.PageToken(x.NextPageToken)
445 }
446 }
447
View as plain text