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 publicca
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 = "publicca:v1alpha1"
90 const apiName = "publicca"
91 const apiVersion = "v1alpha1"
92 const basePath = "https://publicca.googleapis.com/"
93 const basePathTemplate = "https://publicca.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://publicca.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.ExternalAccountKeys = NewProjectsLocationsExternalAccountKeysService(s)
172 return rs
173 }
174
175 type ProjectsLocationsService struct {
176 s *Service
177
178 ExternalAccountKeys *ProjectsLocationsExternalAccountKeysService
179 }
180
181 func NewProjectsLocationsExternalAccountKeysService(s *Service) *ProjectsLocationsExternalAccountKeysService {
182 rs := &ProjectsLocationsExternalAccountKeysService{s: s}
183 return rs
184 }
185
186 type ProjectsLocationsExternalAccountKeysService struct {
187 s *Service
188 }
189
190
191
192
193 type ExternalAccountKey struct {
194
195
196 B64MacKey string `json:"b64MacKey,omitempty"`
197
198
199 KeyId string `json:"keyId,omitempty"`
200
201
202 Name string `json:"name,omitempty"`
203
204
205 googleapi.ServerResponse `json:"-"`
206
207
208
209
210
211 ForceSendFields []string `json:"-"`
212
213
214
215
216 NullFields []string `json:"-"`
217 }
218
219 func (s *ExternalAccountKey) MarshalJSON() ([]byte, error) {
220 type NoMethod ExternalAccountKey
221 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
222 }
223
224 type ProjectsLocationsExternalAccountKeysCreateCall struct {
225 s *Service
226 parent string
227 externalaccountkey *ExternalAccountKey
228 urlParams_ gensupport.URLParams
229 ctx_ context.Context
230 header_ http.Header
231 }
232
233
234
235
236
237
238 func (r *ProjectsLocationsExternalAccountKeysService) Create(parent string, externalaccountkey *ExternalAccountKey) *ProjectsLocationsExternalAccountKeysCreateCall {
239 c := &ProjectsLocationsExternalAccountKeysCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
240 c.parent = parent
241 c.externalaccountkey = externalaccountkey
242 return c
243 }
244
245
246
247
248 func (c *ProjectsLocationsExternalAccountKeysCreateCall) Fields(s ...googleapi.Field) *ProjectsLocationsExternalAccountKeysCreateCall {
249 c.urlParams_.Set("fields", googleapi.CombineFields(s))
250 return c
251 }
252
253
254 func (c *ProjectsLocationsExternalAccountKeysCreateCall) Context(ctx context.Context) *ProjectsLocationsExternalAccountKeysCreateCall {
255 c.ctx_ = ctx
256 return c
257 }
258
259
260
261 func (c *ProjectsLocationsExternalAccountKeysCreateCall) Header() http.Header {
262 if c.header_ == nil {
263 c.header_ = make(http.Header)
264 }
265 return c.header_
266 }
267
268 func (c *ProjectsLocationsExternalAccountKeysCreateCall) doRequest(alt string) (*http.Response, error) {
269 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
270 var body io.Reader = nil
271 body, err := googleapi.WithoutDataWrapper.JSONReader(c.externalaccountkey)
272 if err != nil {
273 return nil, err
274 }
275 c.urlParams_.Set("alt", alt)
276 c.urlParams_.Set("prettyPrint", "false")
277 urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha1/{+parent}/externalAccountKeys")
278 urls += "?" + c.urlParams_.Encode()
279 req, err := http.NewRequest("POST", urls, body)
280 if err != nil {
281 return nil, err
282 }
283 req.Header = reqHeaders
284 googleapi.Expand(req.URL, map[string]string{
285 "parent": c.parent,
286 })
287 return gensupport.SendRequest(c.ctx_, c.s.client, req)
288 }
289
290
291
292
293
294
295
296 func (c *ProjectsLocationsExternalAccountKeysCreateCall) Do(opts ...googleapi.CallOption) (*ExternalAccountKey, error) {
297 gensupport.SetOptions(c.urlParams_, opts...)
298 res, err := c.doRequest("json")
299 if res != nil && res.StatusCode == http.StatusNotModified {
300 if res.Body != nil {
301 res.Body.Close()
302 }
303 return nil, gensupport.WrapError(&googleapi.Error{
304 Code: res.StatusCode,
305 Header: res.Header,
306 })
307 }
308 if err != nil {
309 return nil, err
310 }
311 defer googleapi.CloseBody(res)
312 if err := googleapi.CheckResponse(res); err != nil {
313 return nil, gensupport.WrapError(err)
314 }
315 ret := &ExternalAccountKey{
316 ServerResponse: googleapi.ServerResponse{
317 Header: res.Header,
318 HTTPStatusCode: res.StatusCode,
319 },
320 }
321 target := &ret
322 if err := gensupport.DecodeResponse(target, res); err != nil {
323 return nil, err
324 }
325 return ret, nil
326 }
327
View as plain text