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 verifiedaccess
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 = "verifiedaccess:v1"
90 const apiName = "verifiedaccess"
91 const apiVersion = "v1"
92 const basePath = "https://verifiedaccess.googleapis.com/"
93 const basePathTemplate = "https://verifiedaccess.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://verifiedaccess.mtls.googleapis.com/"
95
96
97 const (
98
99 VerifiedaccessScope = "https://www.googleapis.com/auth/verifiedaccess"
100 )
101
102
103 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
104 scopesOption := internaloption.WithDefaultScopes(
105 "https://www.googleapis.com/auth/verifiedaccess",
106 )
107
108 opts = append([]option.ClientOption{scopesOption}, opts...)
109 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
110 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
111 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
112 opts = append(opts, internaloption.EnableNewAuthLibrary())
113 client, endpoint, err := htransport.NewClient(ctx, opts...)
114 if err != nil {
115 return nil, err
116 }
117 s, err := New(client)
118 if err != nil {
119 return nil, err
120 }
121 if endpoint != "" {
122 s.BasePath = endpoint
123 }
124 return s, nil
125 }
126
127
128
129
130
131
132 func New(client *http.Client) (*Service, error) {
133 if client == nil {
134 return nil, errors.New("client is nil")
135 }
136 s := &Service{client: client, BasePath: basePath}
137 s.Challenge = NewChallengeService(s)
138 return s, nil
139 }
140
141 type Service struct {
142 client *http.Client
143 BasePath string
144 UserAgent string
145
146 Challenge *ChallengeService
147 }
148
149 func (s *Service) userAgent() string {
150 if s.UserAgent == "" {
151 return googleapi.UserAgent
152 }
153 return googleapi.UserAgent + " " + s.UserAgent
154 }
155
156 func NewChallengeService(s *Service) *ChallengeService {
157 rs := &ChallengeService{s: s}
158 return rs
159 }
160
161 type ChallengeService struct {
162 s *Service
163 }
164
165
166 type Challenge struct {
167
168
169 AlternativeChallenge *SignedData `json:"alternativeChallenge,omitempty"`
170
171 Challenge *SignedData `json:"challenge,omitempty"`
172
173
174 googleapi.ServerResponse `json:"-"`
175
176
177
178
179
180 ForceSendFields []string `json:"-"`
181
182
183
184
185 NullFields []string `json:"-"`
186 }
187
188 func (s *Challenge) MarshalJSON() ([]byte, error) {
189 type NoMethod Challenge
190 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
191 }
192
193
194
195
196
197 type Empty struct {
198 }
199
200
201 type SignedData struct {
202
203 Data string `json:"data,omitempty"`
204
205 Signature string `json:"signature,omitempty"`
206
207
208
209
210
211 ForceSendFields []string `json:"-"`
212
213
214
215
216 NullFields []string `json:"-"`
217 }
218
219 func (s *SignedData) MarshalJSON() ([]byte, error) {
220 type NoMethod SignedData
221 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
222 }
223
224
225 type VerifyChallengeResponseRequest struct {
226
227 ChallengeResponse *SignedData `json:"challengeResponse,omitempty"`
228
229
230
231
232
233 ExpectedIdentity string `json:"expectedIdentity,omitempty"`
234
235
236
237
238
239 ForceSendFields []string `json:"-"`
240
241
242
243
244 NullFields []string `json:"-"`
245 }
246
247 func (s *VerifyChallengeResponseRequest) MarshalJSON() ([]byte, error) {
248 type NoMethod VerifyChallengeResponseRequest
249 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
250 }
251
252
253
254 type VerifyChallengeResponseResult struct {
255
256
257 AttestedDeviceId string `json:"attestedDeviceId,omitempty"`
258
259
260 DeviceEnrollmentId string `json:"deviceEnrollmentId,omitempty"`
261
262
263 DevicePermanentId string `json:"devicePermanentId,omitempty"`
264
265
266
267
268 SignedPublicKeyAndChallenge string `json:"signedPublicKeyAndChallenge,omitempty"`
269
270
271
272
273
274 VerificationOutput string `json:"verificationOutput,omitempty"`
275
276
277 googleapi.ServerResponse `json:"-"`
278
279
280
281
282
283 ForceSendFields []string `json:"-"`
284
285
286
287
288 NullFields []string `json:"-"`
289 }
290
291 func (s *VerifyChallengeResponseResult) MarshalJSON() ([]byte, error) {
292 type NoMethod VerifyChallengeResponseResult
293 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
294 }
295
296 type ChallengeCreateCall struct {
297 s *Service
298 empty *Empty
299 urlParams_ gensupport.URLParams
300 ctx_ context.Context
301 header_ http.Header
302 }
303
304
305 func (r *ChallengeService) Create(empty *Empty) *ChallengeCreateCall {
306 c := &ChallengeCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
307 c.empty = empty
308 return c
309 }
310
311
312
313
314 func (c *ChallengeCreateCall) Fields(s ...googleapi.Field) *ChallengeCreateCall {
315 c.urlParams_.Set("fields", googleapi.CombineFields(s))
316 return c
317 }
318
319
320 func (c *ChallengeCreateCall) Context(ctx context.Context) *ChallengeCreateCall {
321 c.ctx_ = ctx
322 return c
323 }
324
325
326
327 func (c *ChallengeCreateCall) Header() http.Header {
328 if c.header_ == nil {
329 c.header_ = make(http.Header)
330 }
331 return c.header_
332 }
333
334 func (c *ChallengeCreateCall) doRequest(alt string) (*http.Response, error) {
335 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
336 var body io.Reader = nil
337 body, err := googleapi.WithoutDataWrapper.JSONReader(c.empty)
338 if err != nil {
339 return nil, err
340 }
341 c.urlParams_.Set("alt", alt)
342 c.urlParams_.Set("prettyPrint", "false")
343 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/challenge")
344 urls += "?" + c.urlParams_.Encode()
345 req, err := http.NewRequest("POST", urls, body)
346 if err != nil {
347 return nil, err
348 }
349 req.Header = reqHeaders
350 return gensupport.SendRequest(c.ctx_, c.s.client, req)
351 }
352
353
354
355
356
357
358 func (c *ChallengeCreateCall) Do(opts ...googleapi.CallOption) (*Challenge, error) {
359 gensupport.SetOptions(c.urlParams_, opts...)
360 res, err := c.doRequest("json")
361 if res != nil && res.StatusCode == http.StatusNotModified {
362 if res.Body != nil {
363 res.Body.Close()
364 }
365 return nil, gensupport.WrapError(&googleapi.Error{
366 Code: res.StatusCode,
367 Header: res.Header,
368 })
369 }
370 if err != nil {
371 return nil, err
372 }
373 defer googleapi.CloseBody(res)
374 if err := googleapi.CheckResponse(res); err != nil {
375 return nil, gensupport.WrapError(err)
376 }
377 ret := &Challenge{
378 ServerResponse: googleapi.ServerResponse{
379 Header: res.Header,
380 HTTPStatusCode: res.StatusCode,
381 },
382 }
383 target := &ret
384 if err := gensupport.DecodeResponse(target, res); err != nil {
385 return nil, err
386 }
387 return ret, nil
388 }
389
390 type ChallengeVerifyCall struct {
391 s *Service
392 verifychallengeresponserequest *VerifyChallengeResponseRequest
393 urlParams_ gensupport.URLParams
394 ctx_ context.Context
395 header_ http.Header
396 }
397
398
399 func (r *ChallengeService) Verify(verifychallengeresponserequest *VerifyChallengeResponseRequest) *ChallengeVerifyCall {
400 c := &ChallengeVerifyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
401 c.verifychallengeresponserequest = verifychallengeresponserequest
402 return c
403 }
404
405
406
407
408 func (c *ChallengeVerifyCall) Fields(s ...googleapi.Field) *ChallengeVerifyCall {
409 c.urlParams_.Set("fields", googleapi.CombineFields(s))
410 return c
411 }
412
413
414 func (c *ChallengeVerifyCall) Context(ctx context.Context) *ChallengeVerifyCall {
415 c.ctx_ = ctx
416 return c
417 }
418
419
420
421 func (c *ChallengeVerifyCall) Header() http.Header {
422 if c.header_ == nil {
423 c.header_ = make(http.Header)
424 }
425 return c.header_
426 }
427
428 func (c *ChallengeVerifyCall) doRequest(alt string) (*http.Response, error) {
429 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
430 var body io.Reader = nil
431 body, err := googleapi.WithoutDataWrapper.JSONReader(c.verifychallengeresponserequest)
432 if err != nil {
433 return nil, err
434 }
435 c.urlParams_.Set("alt", alt)
436 c.urlParams_.Set("prettyPrint", "false")
437 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/challenge:verify")
438 urls += "?" + c.urlParams_.Encode()
439 req, err := http.NewRequest("POST", urls, body)
440 if err != nil {
441 return nil, err
442 }
443 req.Header = reqHeaders
444 return gensupport.SendRequest(c.ctx_, c.s.client, req)
445 }
446
447
448
449
450
451
452
453 func (c *ChallengeVerifyCall) Do(opts ...googleapi.CallOption) (*VerifyChallengeResponseResult, error) {
454 gensupport.SetOptions(c.urlParams_, opts...)
455 res, err := c.doRequest("json")
456 if res != nil && res.StatusCode == http.StatusNotModified {
457 if res.Body != nil {
458 res.Body.Close()
459 }
460 return nil, gensupport.WrapError(&googleapi.Error{
461 Code: res.StatusCode,
462 Header: res.Header,
463 })
464 }
465 if err != nil {
466 return nil, err
467 }
468 defer googleapi.CloseBody(res)
469 if err := googleapi.CheckResponse(res); err != nil {
470 return nil, gensupport.WrapError(err)
471 }
472 ret := &VerifyChallengeResponseResult{
473 ServerResponse: googleapi.ServerResponse{
474 Header: res.Header,
475 HTTPStatusCode: res.StatusCode,
476 },
477 }
478 target := &ret
479 if err := gensupport.DecodeResponse(target, res); err != nil {
480 return nil, err
481 }
482 return ret, nil
483 }
484
View as plain text