Debian Codegraph @

apihub/apiv1/api_hub_plugin_client.go

raw
1 // Copyright 2025 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17 package apihub
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 apihubpb "cloud.google.com/go/apihub/apiv1/apihubpb"
30 "cloud.google.com/go/longrunning"
31 lroauto "cloud.google.com/go/longrunning/autogen"
32 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
33 gax "github.com/googleapis/gax-go/v2"
34 "google.golang.org/api/iterator"
35 "google.golang.org/api/option"
36 "google.golang.org/api/option/internaloption"
37 httptransport "google.golang.org/api/transport/http"
38 locationpb "google.golang.org/genproto/googleapis/cloud/location"
39 "google.golang.org/grpc"
40 "google.golang.org/protobuf/encoding/protojson"
41 "google.golang.org/protobuf/proto"
42 )
43
44 var newApiHubPluginClientHook clientHook
45
46 // ApiHubPluginCallOptions contains the retry settings for each method of ApiHubPluginClient.
47 type ApiHubPluginCallOptions struct {
48 GetPlugin []gax.CallOption
49 EnablePlugin []gax.CallOption
50 DisablePlugin []gax.CallOption
51 CreatePlugin []gax.CallOption
52 ListPlugins []gax.CallOption
53 DeletePlugin []gax.CallOption
54 CreatePluginInstance []gax.CallOption
55 ExecutePluginInstanceAction []gax.CallOption
56 GetPluginInstance []gax.CallOption
57 ListPluginInstances []gax.CallOption
58 EnablePluginInstanceAction []gax.CallOption
59 DisablePluginInstanceAction []gax.CallOption
60 UpdatePluginInstance []gax.CallOption
61 DeletePluginInstance []gax.CallOption
62 GetLocation []gax.CallOption
63 ListLocations []gax.CallOption
64 CancelOperation []gax.CallOption
65 DeleteOperation []gax.CallOption
66 GetOperation []gax.CallOption
67 ListOperations []gax.CallOption
68 }
69
70 func defaultApiHubPluginRESTCallOptions() *ApiHubPluginCallOptions {
71 return &ApiHubPluginCallOptions{
72 GetPlugin: []gax.CallOption{
73 gax.WithTimeout(60000 * time.Millisecond),
74 gax.WithRetry(func() gax.Retryer {
75 return gax.OnHTTPCodes(gax.Backoff{
76 Initial: 1000 * time.Millisecond,
77 Max: 10000 * time.Millisecond,
78 Multiplier: 1.30,
79 },
80 http.StatusServiceUnavailable)
81 }),
82 },
83 EnablePlugin: []gax.CallOption{
84 gax.WithTimeout(60000 * time.Millisecond),
85 },
86 DisablePlugin: []gax.CallOption{
87 gax.WithTimeout(60000 * time.Millisecond),
88 },
89 CreatePlugin: []gax.CallOption{},
90 ListPlugins: []gax.CallOption{},
91 DeletePlugin: []gax.CallOption{},
92 CreatePluginInstance: []gax.CallOption{},
93 ExecutePluginInstanceAction: []gax.CallOption{},
94 GetPluginInstance: []gax.CallOption{},
95 ListPluginInstances: []gax.CallOption{},
96 EnablePluginInstanceAction: []gax.CallOption{},
97 DisablePluginInstanceAction: []gax.CallOption{},
98 UpdatePluginInstance: []gax.CallOption{},
99 DeletePluginInstance: []gax.CallOption{},
100 GetLocation: []gax.CallOption{},
101 ListLocations: []gax.CallOption{},
102 CancelOperation: []gax.CallOption{},
103 DeleteOperation: []gax.CallOption{},
104 GetOperation: []gax.CallOption{},
105 ListOperations: []gax.CallOption{},
106 }
107 }
108
109 // internalApiHubPluginClient is an interface that defines the methods available from API hub API.
110 type internalApiHubPluginClient interface {
111 Close() error
112 setGoogleClientInfo(...string)
113 Connection() *grpc.ClientConn
114 GetPlugin(context.Context, *apihubpb.GetPluginRequest, ...gax.CallOption) (*apihubpb.Plugin, error)
115 EnablePlugin(context.Context, *apihubpb.EnablePluginRequest, ...gax.CallOption) (*apihubpb.Plugin, error)
116 DisablePlugin(context.Context, *apihubpb.DisablePluginRequest, ...gax.CallOption) (*apihubpb.Plugin, error)
117 CreatePlugin(context.Context, *apihubpb.CreatePluginRequest, ...gax.CallOption) (*apihubpb.Plugin, error)
118 ListPlugins(context.Context, *apihubpb.ListPluginsRequest, ...gax.CallOption) *PluginIterator
119 DeletePlugin(context.Context, *apihubpb.DeletePluginRequest, ...gax.CallOption) (*DeletePluginOperation, error)
120 DeletePluginOperation(name string) *DeletePluginOperation
121 CreatePluginInstance(context.Context, *apihubpb.CreatePluginInstanceRequest, ...gax.CallOption) (*CreatePluginInstanceOperation, error)
122 CreatePluginInstanceOperation(name string) *CreatePluginInstanceOperation
123 ExecutePluginInstanceAction(context.Context, *apihubpb.ExecutePluginInstanceActionRequest, ...gax.CallOption) (*ExecutePluginInstanceActionOperation, error)
124 ExecutePluginInstanceActionOperation(name string) *ExecutePluginInstanceActionOperation
125 GetPluginInstance(context.Context, *apihubpb.GetPluginInstanceRequest, ...gax.CallOption) (*apihubpb.PluginInstance, error)
126 ListPluginInstances(context.Context, *apihubpb.ListPluginInstancesRequest, ...gax.CallOption) *PluginInstanceIterator
127 EnablePluginInstanceAction(context.Context, *apihubpb.EnablePluginInstanceActionRequest, ...gax.CallOption) (*EnablePluginInstanceActionOperation, error)
128 EnablePluginInstanceActionOperation(name string) *EnablePluginInstanceActionOperation
129 DisablePluginInstanceAction(context.Context, *apihubpb.DisablePluginInstanceActionRequest, ...gax.CallOption) (*DisablePluginInstanceActionOperation, error)
130 DisablePluginInstanceActionOperation(name string) *DisablePluginInstanceActionOperation
131 UpdatePluginInstance(context.Context, *apihubpb.UpdatePluginInstanceRequest, ...gax.CallOption) (*apihubpb.PluginInstance, error)
132 DeletePluginInstance(context.Context, *apihubpb.DeletePluginInstanceRequest, ...gax.CallOption) (*DeletePluginInstanceOperation, error)
133 DeletePluginInstanceOperation(name string) *DeletePluginInstanceOperation
134 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
135 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
136 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
137 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
138 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
139 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
140 }
141
142 // ApiHubPluginClient is a client for interacting with API hub API.
143 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
144 //
145 // This service is used for managing plugins inside the API Hub.
146 type ApiHubPluginClient struct {
147 // The internal transport-dependent client.
148 internalClient internalApiHubPluginClient
149
150 // The call options for this service.
151 CallOptions *ApiHubPluginCallOptions
152
153 // LROClient is used internally to handle long-running operations.
154 // It is exposed so that its CallOptions can be modified if required.
155 // Users should not Close this client.
156 LROClient *lroauto.OperationsClient
157 }
158
159 // Wrapper methods routed to the internal client.
160
161 // Close closes the connection to the API service. The user should invoke this when
162 // the client is no longer required.
163 func (c *ApiHubPluginClient) Close() error {
164 return c.internalClient.Close()
165 }
166
167 // setGoogleClientInfo sets the name and version of the application in
168 // the `x-goog-api-client` header passed on each request. Intended for
169 // use by Google-written clients.
170 func (c *ApiHubPluginClient) setGoogleClientInfo(keyval ...string) {
171 c.internalClient.setGoogleClientInfo(keyval...)
172 }
173
174 // Connection returns a connection to the API service.
175 //
176 // Deprecated: Connections are now pooled so this method does not always
177 // return the same resource.
178 func (c *ApiHubPluginClient) Connection() *grpc.ClientConn {
179 return c.internalClient.Connection()
180 }
181
182 // GetPlugin get an API Hub plugin.
183 func (c *ApiHubPluginClient) GetPlugin(ctx context.Context, req *apihubpb.GetPluginRequest, opts ...gax.CallOption) (*apihubpb.Plugin, error) {
184 return c.internalClient.GetPlugin(ctx, req, opts...)
185 }
186
187 // EnablePlugin enables a plugin.
188 // The state of the plugin after enabling is ENABLED
189 func (c *ApiHubPluginClient) EnablePlugin(ctx context.Context, req *apihubpb.EnablePluginRequest, opts ...gax.CallOption) (*apihubpb.Plugin, error) {
190 return c.internalClient.EnablePlugin(ctx, req, opts...)
191 }
192
193 // DisablePlugin disables a plugin.
194 // The state of the plugin after disabling is DISABLED
195 func (c *ApiHubPluginClient) DisablePlugin(ctx context.Context, req *apihubpb.DisablePluginRequest, opts ...gax.CallOption) (*apihubpb.Plugin, error) {
196 return c.internalClient.DisablePlugin(ctx, req, opts...)
197 }
198
199 // CreatePlugin create an API Hub plugin resource in the API hub.
200 // Once a plugin is created, it can be used to create plugin instances.
201 func (c *ApiHubPluginClient) CreatePlugin(ctx context.Context, req *apihubpb.CreatePluginRequest, opts ...gax.CallOption) (*apihubpb.Plugin, error) {
202 return c.internalClient.CreatePlugin(ctx, req, opts...)
203 }
204
205 // ListPlugins list all the plugins in a given project and location.
206 func (c *ApiHubPluginClient) ListPlugins(ctx context.Context, req *apihubpb.ListPluginsRequest, opts ...gax.CallOption) *PluginIterator {
207 return c.internalClient.ListPlugins(ctx, req, opts...)
208 }
209
210 // DeletePlugin delete a Plugin in API hub.
211 // Note, only user owned plugins can be deleted via this method.
212 func (c *ApiHubPluginClient) DeletePlugin(ctx context.Context, req *apihubpb.DeletePluginRequest, opts ...gax.CallOption) (*DeletePluginOperation, error) {
213 return c.internalClient.DeletePlugin(ctx, req, opts...)
214 }
215
216 // DeletePluginOperation returns a new DeletePluginOperation from a given name.
217 // The name must be that of a previously created DeletePluginOperation, possibly from a different process.
218 func (c *ApiHubPluginClient) DeletePluginOperation(name string) *DeletePluginOperation {
219 return c.internalClient.DeletePluginOperation(name)
220 }
221
222 // CreatePluginInstance creates a Plugin instance in the API hub.
223 func (c *ApiHubPluginClient) CreatePluginInstance(ctx context.Context, req *apihubpb.CreatePluginInstanceRequest, opts ...gax.CallOption) (*CreatePluginInstanceOperation, error) {
224 return c.internalClient.CreatePluginInstance(ctx, req, opts...)
225 }
226
227 // CreatePluginInstanceOperation returns a new CreatePluginInstanceOperation from a given name.
228 // The name must be that of a previously created CreatePluginInstanceOperation, possibly from a different process.
229 func (c *ApiHubPluginClient) CreatePluginInstanceOperation(name string) *CreatePluginInstanceOperation {
230 return c.internalClient.CreatePluginInstanceOperation(name)
231 }
232
233 // ExecutePluginInstanceAction executes a plugin instance in the API hub.
234 func (c *ApiHubPluginClient) ExecutePluginInstanceAction(ctx context.Context, req *apihubpb.ExecutePluginInstanceActionRequest, opts ...gax.CallOption) (*ExecutePluginInstanceActionOperation, error) {
235 return c.internalClient.ExecutePluginInstanceAction(ctx, req, opts...)
236 }
237
238 // ExecutePluginInstanceActionOperation returns a new ExecutePluginInstanceActionOperation from a given name.
239 // The name must be that of a previously created ExecutePluginInstanceActionOperation, possibly from a different process.
240 func (c *ApiHubPluginClient) ExecutePluginInstanceActionOperation(name string) *ExecutePluginInstanceActionOperation {
241 return c.internalClient.ExecutePluginInstanceActionOperation(name)
242 }
243
244 // GetPluginInstance get an API Hub plugin instance.
245 func (c *ApiHubPluginClient) GetPluginInstance(ctx context.Context, req *apihubpb.GetPluginInstanceRequest, opts ...gax.CallOption) (*apihubpb.PluginInstance, error) {
246 return c.internalClient.GetPluginInstance(ctx, req, opts...)
247 }
248
249 // ListPluginInstances list all the plugins in a given project and location.
250 // - can be used as wildcard value for {plugin_id}
251 func (c *ApiHubPluginClient) ListPluginInstances(ctx context.Context, req *apihubpb.ListPluginInstancesRequest, opts ...gax.CallOption) *PluginInstanceIterator {
252 return c.internalClient.ListPluginInstances(ctx, req, opts...)
253 }
254
255 // EnablePluginInstanceAction enables a plugin instance in the API hub.
256 func (c *ApiHubPluginClient) EnablePluginInstanceAction(ctx context.Context, req *apihubpb.EnablePluginInstanceActionRequest, opts ...gax.CallOption) (*EnablePluginInstanceActionOperation, error) {
257 return c.internalClient.EnablePluginInstanceAction(ctx, req, opts...)
258 }
259
260 // EnablePluginInstanceActionOperation returns a new EnablePluginInstanceActionOperation from a given name.
261 // The name must be that of a previously created EnablePluginInstanceActionOperation, possibly from a different process.
262 func (c *ApiHubPluginClient) EnablePluginInstanceActionOperation(name string) *EnablePluginInstanceActionOperation {
263 return c.internalClient.EnablePluginInstanceActionOperation(name)
264 }
265
266 // DisablePluginInstanceAction disables a plugin instance in the API hub.
267 func (c *ApiHubPluginClient) DisablePluginInstanceAction(ctx context.Context, req *apihubpb.DisablePluginInstanceActionRequest, opts ...gax.CallOption) (*DisablePluginInstanceActionOperation, error) {
268 return c.internalClient.DisablePluginInstanceAction(ctx, req, opts...)
269 }
270
271 // DisablePluginInstanceActionOperation returns a new DisablePluginInstanceActionOperation from a given name.
272 // The name must be that of a previously created DisablePluginInstanceActionOperation, possibly from a different process.
273 func (c *ApiHubPluginClient) DisablePluginInstanceActionOperation(name string) *DisablePluginInstanceActionOperation {
274 return c.internalClient.DisablePluginInstanceActionOperation(name)
275 }
276
277 // UpdatePluginInstance updates a plugin instance in the API hub.
278 // The following fields in the
279 // plugin_instance can be updated
280 // currently:
281 //
282 // display_name
283 //
284 // schedule_cron_expression
285 //
286 // The
287 // update_mask
288 // should be used to specify the fields being updated.
289 //
290 // To update the
291 // auth_config and
292 // additional_config
293 // of the plugin instance, use the
294 // ApplyPluginInstanceConfig
295 // method.
296 func (c *ApiHubPluginClient) UpdatePluginInstance(ctx context.Context, req *apihubpb.UpdatePluginInstanceRequest, opts ...gax.CallOption) (*apihubpb.PluginInstance, error) {
297 return c.internalClient.UpdatePluginInstance(ctx, req, opts...)
298 }
299
300 // DeletePluginInstance deletes a plugin instance in the API hub.
301 func (c *ApiHubPluginClient) DeletePluginInstance(ctx context.Context, req *apihubpb.DeletePluginInstanceRequest, opts ...gax.CallOption) (*DeletePluginInstanceOperation, error) {
302 return c.internalClient.DeletePluginInstance(ctx, req, opts...)
303 }
304
305 // DeletePluginInstanceOperation returns a new DeletePluginInstanceOperation from a given name.
306 // The name must be that of a previously created DeletePluginInstanceOperation, possibly from a different process.
307 func (c *ApiHubPluginClient) DeletePluginInstanceOperation(name string) *DeletePluginInstanceOperation {
308 return c.internalClient.DeletePluginInstanceOperation(name)
309 }
310
311 // GetLocation gets information about a location.
312 func (c *ApiHubPluginClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
313 return c.internalClient.GetLocation(ctx, req, opts...)
314 }
315
316 // ListLocations lists information about the supported locations for this service.
317 func (c *ApiHubPluginClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
318 return c.internalClient.ListLocations(ctx, req, opts...)
319 }
320
321 // CancelOperation is a utility method from google.longrunning.Operations.
322 func (c *ApiHubPluginClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
323 return c.internalClient.CancelOperation(ctx, req, opts...)
324 }
325
326 // DeleteOperation is a utility method from google.longrunning.Operations.
327 func (c *ApiHubPluginClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
328 return c.internalClient.DeleteOperation(ctx, req, opts...)
329 }
330
331 // GetOperation is a utility method from google.longrunning.Operations.
332 func (c *ApiHubPluginClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
333 return c.internalClient.GetOperation(ctx, req, opts...)
334 }
335
336 // ListOperations is a utility method from google.longrunning.Operations.
337 func (c *ApiHubPluginClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
338 return c.internalClient.ListOperations(ctx, req, opts...)
339 }
340
341 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
342 type apiHubPluginRESTClient struct {
343 // The http endpoint to connect to.
344 endpoint string
345
346 // The http client.
347 httpClient *http.Client
348
349 // LROClient is used internally to handle long-running operations.
350 // It is exposed so that its CallOptions can be modified if required.
351 // Users should not Close this client.
352 LROClient **lroauto.OperationsClient
353
354 // The x-goog-* headers to be sent with each request.
355 xGoogHeaders []string
356
357 // Points back to the CallOptions field of the containing ApiHubPluginClient
358 CallOptions **ApiHubPluginCallOptions
359
360 logger *slog.Logger
361 }
362
363 // NewApiHubPluginRESTClient creates a new api hub plugin rest client.
364 //
365 // This service is used for managing plugins inside the API Hub.
366 func NewApiHubPluginRESTClient(ctx context.Context, opts ...option.ClientOption) (*ApiHubPluginClient, error) {
367 clientOpts := append(defaultApiHubPluginRESTClientOptions(), opts...)
368 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
369 if err != nil {
370 return nil, err
371 }
372
373 callOpts := defaultApiHubPluginRESTCallOptions()
374 c := &apiHubPluginRESTClient{
375 endpoint: endpoint,
376 httpClient: httpClient,
377 CallOptions: &callOpts,
378 logger: internaloption.GetLogger(opts),
379 }
380 c.setGoogleClientInfo()
381
382 lroOpts := []option.ClientOption{
383 option.WithHTTPClient(httpClient),
384 option.WithEndpoint(endpoint),
385 }
386 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
387 if err != nil {
388 return nil, err
389 }
390 c.LROClient = &opClient
391
392 return &ApiHubPluginClient{internalClient: c, CallOptions: callOpts}, nil
393 }
394
395 func defaultApiHubPluginRESTClientOptions() []option.ClientOption {
396 return []option.ClientOption{
397 internaloption.WithDefaultEndpoint("https://apihub.googleapis.com"),
398 internaloption.WithDefaultEndpointTemplate("https://apihub.UNIVERSE_DOMAIN"),
399 internaloption.WithDefaultMTLSEndpoint("https://apihub.mtls.googleapis.com"),
400 internaloption.WithDefaultUniverseDomain("googleapis.com"),
401 internaloption.WithDefaultAudience("https://apihub.googleapis.com/"),
402 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
403 internaloption.EnableNewAuthLibrary(),
404 }
405 }
406
407 // setGoogleClientInfo sets the name and version of the application in
408 // the `x-goog-api-client` header passed on each request. Intended for
409 // use by Google-written clients.
410 func (c *apiHubPluginRESTClient) setGoogleClientInfo(keyval ...string) {
411 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
412 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
413 c.xGoogHeaders = []string{
414 "x-goog-api-client", gax.XGoogHeader(kv...),
415 }
416 }
417
418 // Close closes the connection to the API service. The user should invoke this when
419 // the client is no longer required.
420 func (c *apiHubPluginRESTClient) Close() error {
421 // Replace httpClient with nil to force cleanup.
422 c.httpClient = nil
423 return nil
424 }
425
426 // Connection returns a connection to the API service.
427 //
428 // Deprecated: This method always returns nil.
429 func (c *apiHubPluginRESTClient) Connection() *grpc.ClientConn {
430 return nil
431 }
432
433 // GetPlugin get an API Hub plugin.
434 func (c *apiHubPluginRESTClient) GetPlugin(ctx context.Context, req *apihubpb.GetPluginRequest, opts ...gax.CallOption) (*apihubpb.Plugin, error) {
435 baseUrl, err := url.Parse(c.endpoint)
436 if err != nil {
437 return nil, err
438 }
439 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
440
441 params := url.Values{}
442 params.Add("$alt", "json;enum-encoding=int")
443
444 baseUrl.RawQuery = params.Encode()
445
446 // Build HTTP headers from client and context metadata.
447 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
448
449 hds = append(c.xGoogHeaders, hds...)
450 hds = append(hds, "Content-Type", "application/json")
451 headers := gax.BuildHeaders(ctx, hds...)
452 opts = append((*c.CallOptions).GetPlugin[0:len((*c.CallOptions).GetPlugin):len((*c.CallOptions).GetPlugin)], opts...)
453 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
454 resp := &apihubpb.Plugin{}
455 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
456 if settings.Path != "" {
457 baseUrl.Path = settings.Path
458 }
459 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
460 if err != nil {
461 return err
462 }
463 httpReq = httpReq.WithContext(ctx)
464 httpReq.Header = headers
465
466 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetPlugin")
467 if err != nil {
468 return err
469 }
470
471 if err := unm.Unmarshal(buf, resp); err != nil {
472 return err
473 }
474
475 return nil
476 }, opts...)
477 if e != nil {
478 return nil, e
479 }
480 return resp, nil
481 }
482
483 // EnablePlugin enables a plugin.
484 // The state of the plugin after enabling is ENABLED
485 func (c *apiHubPluginRESTClient) EnablePlugin(ctx context.Context, req *apihubpb.EnablePluginRequest, opts ...gax.CallOption) (*apihubpb.Plugin, error) {
486 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
487 jsonReq, err := m.Marshal(req)
488 if err != nil {
489 return nil, err
490 }
491
492 baseUrl, err := url.Parse(c.endpoint)
493 if err != nil {
494 return nil, err
495 }
496 baseUrl.Path += fmt.Sprintf("/v1/%v:enable", req.GetName())
497
498 params := url.Values{}
499 params.Add("$alt", "json;enum-encoding=int")
500
501 baseUrl.RawQuery = params.Encode()
502
503 // Build HTTP headers from client and context metadata.
504 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
505
506 hds = append(c.xGoogHeaders, hds...)
507 hds = append(hds, "Content-Type", "application/json")
508 headers := gax.BuildHeaders(ctx, hds...)
509 opts = append((*c.CallOptions).EnablePlugin[0:len((*c.CallOptions).EnablePlugin):len((*c.CallOptions).EnablePlugin)], opts...)
510 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
511 resp := &apihubpb.Plugin{}
512 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
513 if settings.Path != "" {
514 baseUrl.Path = settings.Path
515 }
516 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
517 if err != nil {
518 return err
519 }
520 httpReq = httpReq.WithContext(ctx)
521 httpReq.Header = headers
522
523 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "EnablePlugin")
524 if err != nil {
525 return err
526 }
527
528 if err := unm.Unmarshal(buf, resp); err != nil {
529 return err
530 }
531
532 return nil
533 }, opts...)
534 if e != nil {
535 return nil, e
536 }
537 return resp, nil
538 }
539
540 // DisablePlugin disables a plugin.
541 // The state of the plugin after disabling is DISABLED
542 func (c *apiHubPluginRESTClient) DisablePlugin(ctx context.Context, req *apihubpb.DisablePluginRequest, opts ...gax.CallOption) (*apihubpb.Plugin, error) {
543 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
544 jsonReq, err := m.Marshal(req)
545 if err != nil {
546 return nil, err
547 }
548
549 baseUrl, err := url.Parse(c.endpoint)
550 if err != nil {
551 return nil, err
552 }
553 baseUrl.Path += fmt.Sprintf("/v1/%v:disable", req.GetName())
554
555 params := url.Values{}
556 params.Add("$alt", "json;enum-encoding=int")
557
558 baseUrl.RawQuery = params.Encode()
559
560 // Build HTTP headers from client and context metadata.
561 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
562
563 hds = append(c.xGoogHeaders, hds...)
564 hds = append(hds, "Content-Type", "application/json")
565 headers := gax.BuildHeaders(ctx, hds...)
566 opts = append((*c.CallOptions).DisablePlugin[0:len((*c.CallOptions).DisablePlugin):len((*c.CallOptions).DisablePlugin)], opts...)
567 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
568 resp := &apihubpb.Plugin{}
569 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
570 if settings.Path != "" {
571 baseUrl.Path = settings.Path
572 }
573 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
574 if err != nil {
575 return err
576 }
577 httpReq = httpReq.WithContext(ctx)
578 httpReq.Header = headers
579
580 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "DisablePlugin")
581 if err != nil {
582 return err
583 }
584
585 if err := unm.Unmarshal(buf, resp); err != nil {
586 return err
587 }
588
589 return nil
590 }, opts...)
591 if e != nil {
592 return nil, e
593 }
594 return resp, nil
595 }
596
597 // CreatePlugin create an API Hub plugin resource in the API hub.
598 // Once a plugin is created, it can be used to create plugin instances.
599 func (c *apiHubPluginRESTClient) CreatePlugin(ctx context.Context, req *apihubpb.CreatePluginRequest, opts ...gax.CallOption) (*apihubpb.Plugin, error) {
600 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
601 body := req.GetPlugin()
602 jsonReq, err := m.Marshal(body)
603 if err != nil {
604 return nil, err
605 }
606
607 baseUrl, err := url.Parse(c.endpoint)
608 if err != nil {
609 return nil, err
610 }
611 baseUrl.Path += fmt.Sprintf("/v1/%v/plugins", req.GetParent())
612
613 params := url.Values{}
614 params.Add("$alt", "json;enum-encoding=int")
615 if req.GetPluginId() != "" {
616 params.Add("pluginId", fmt.Sprintf("%v", req.GetPluginId()))
617 }
618
619 baseUrl.RawQuery = params.Encode()
620
621 // Build HTTP headers from client and context metadata.
622 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
623
624 hds = append(c.xGoogHeaders, hds...)
625 hds = append(hds, "Content-Type", "application/json")
626 headers := gax.BuildHeaders(ctx, hds...)
627 opts = append((*c.CallOptions).CreatePlugin[0:len((*c.CallOptions).CreatePlugin):len((*c.CallOptions).CreatePlugin)], opts...)
628 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
629 resp := &apihubpb.Plugin{}
630 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
631 if settings.Path != "" {
632 baseUrl.Path = settings.Path
633 }
634 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
635 if err != nil {
636 return err
637 }
638 httpReq = httpReq.WithContext(ctx)
639 httpReq.Header = headers
640
641 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreatePlugin")
642 if err != nil {
643 return err
644 }
645
646 if err := unm.Unmarshal(buf, resp); err != nil {
647 return err
648 }
649
650 return nil
651 }, opts...)
652 if e != nil {
653 return nil, e
654 }
655 return resp, nil
656 }
657
658 // ListPlugins list all the plugins in a given project and location.
659 func (c *apiHubPluginRESTClient) ListPlugins(ctx context.Context, req *apihubpb.ListPluginsRequest, opts ...gax.CallOption) *PluginIterator {
660 it := &PluginIterator{}
661 req = proto.Clone(req).(*apihubpb.ListPluginsRequest)
662 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
663 it.InternalFetch = func(pageSize int, pageToken string) ([]*apihubpb.Plugin, string, error) {
664 resp := &apihubpb.ListPluginsResponse{}
665 if pageToken != "" {
666 req.PageToken = pageToken
667 }
668 if pageSize > math.MaxInt32 {
669 req.PageSize = math.MaxInt32
670 } else if pageSize != 0 {
671 req.PageSize = int32(pageSize)
672 }
673 baseUrl, err := url.Parse(c.endpoint)
674 if err != nil {
675 return nil, "", err
676 }
677 baseUrl.Path += fmt.Sprintf("/v1/%v/plugins", req.GetParent())
678
679 params := url.Values{}
680 params.Add("$alt", "json;enum-encoding=int")
681 if req.GetFilter() != "" {
682 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
683 }
684 if req.GetPageSize() != 0 {
685 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
686 }
687 if req.GetPageToken() != "" {
688 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
689 }
690
691 baseUrl.RawQuery = params.Encode()
692
693 // Build HTTP headers from client and context metadata.
694 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
695 headers := gax.BuildHeaders(ctx, hds...)
696 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
697 if settings.Path != "" {
698 baseUrl.Path = settings.Path
699 }
700 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
701 if err != nil {
702 return err
703 }
704 httpReq.Header = headers
705
706 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListPlugins")
707 if err != nil {
708 return err
709 }
710 if err := unm.Unmarshal(buf, resp); err != nil {
711 return err
712 }
713
714 return nil
715 }, opts...)
716 if e != nil {
717 return nil, "", e
718 }
719 it.Response = resp
720 return resp.GetPlugins(), resp.GetNextPageToken(), nil
721 }
722
723 fetch := func(pageSize int, pageToken string) (string, error) {
724 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
725 if err != nil {
726 return "", err
727 }
728 it.items = append(it.items, items...)
729 return nextPageToken, nil
730 }
731
732 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
733 it.pageInfo.MaxSize = int(req.GetPageSize())
734 it.pageInfo.Token = req.GetPageToken()
735
736 return it
737 }
738
739 // DeletePlugin delete a Plugin in API hub.
740 // Note, only user owned plugins can be deleted via this method.
741 func (c *apiHubPluginRESTClient) DeletePlugin(ctx context.Context, req *apihubpb.DeletePluginRequest, opts ...gax.CallOption) (*DeletePluginOperation, error) {
742 baseUrl, err := url.Parse(c.endpoint)
743 if err != nil {
744 return nil, err
745 }
746 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
747
748 params := url.Values{}
749 params.Add("$alt", "json;enum-encoding=int")
750
751 baseUrl.RawQuery = params.Encode()
752
753 // Build HTTP headers from client and context metadata.
754 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
755
756 hds = append(c.xGoogHeaders, hds...)
757 hds = append(hds, "Content-Type", "application/json")
758 headers := gax.BuildHeaders(ctx, hds...)
759 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
760 resp := &longrunningpb.Operation{}
761 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
762 if settings.Path != "" {
763 baseUrl.Path = settings.Path
764 }
765 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
766 if err != nil {
767 return err
768 }
769 httpReq = httpReq.WithContext(ctx)
770 httpReq.Header = headers
771
772 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeletePlugin")
773 if err != nil {
774 return err
775 }
776 if err := unm.Unmarshal(buf, resp); err != nil {
777 return err
778 }
779
780 return nil
781 }, opts...)
782 if e != nil {
783 return nil, e
784 }
785
786 override := fmt.Sprintf("/v1/%s", resp.GetName())
787 return &DeletePluginOperation{
788 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
789 pollPath: override,
790 }, nil
791 }
792
793 // CreatePluginInstance creates a Plugin instance in the API hub.
794 func (c *apiHubPluginRESTClient) CreatePluginInstance(ctx context.Context, req *apihubpb.CreatePluginInstanceRequest, opts ...gax.CallOption) (*CreatePluginInstanceOperation, error) {
795 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
796 body := req.GetPluginInstance()
797 jsonReq, err := m.Marshal(body)
798 if err != nil {
799 return nil, err
800 }
801
802 baseUrl, err := url.Parse(c.endpoint)
803 if err != nil {
804 return nil, err
805 }
806 baseUrl.Path += fmt.Sprintf("/v1/%v/instances", req.GetParent())
807
808 params := url.Values{}
809 params.Add("$alt", "json;enum-encoding=int")
810 if req.GetPluginInstanceId() != "" {
811 params.Add("pluginInstanceId", fmt.Sprintf("%v", req.GetPluginInstanceId()))
812 }
813
814 baseUrl.RawQuery = params.Encode()
815
816 // Build HTTP headers from client and context metadata.
817 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
818
819 hds = append(c.xGoogHeaders, hds...)
820 hds = append(hds, "Content-Type", "application/json")
821 headers := gax.BuildHeaders(ctx, hds...)
822 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
823 resp := &longrunningpb.Operation{}
824 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
825 if settings.Path != "" {
826 baseUrl.Path = settings.Path
827 }
828 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
829 if err != nil {
830 return err
831 }
832 httpReq = httpReq.WithContext(ctx)
833 httpReq.Header = headers
834
835 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreatePluginInstance")
836 if err != nil {
837 return err
838 }
839 if err := unm.Unmarshal(buf, resp); err != nil {
840 return err
841 }
842
843 return nil
844 }, opts...)
845 if e != nil {
846 return nil, e
847 }
848
849 override := fmt.Sprintf("/v1/%s", resp.GetName())
850 return &CreatePluginInstanceOperation{
851 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
852 pollPath: override,
853 }, nil
854 }
855
856 // ExecutePluginInstanceAction executes a plugin instance in the API hub.
857 func (c *apiHubPluginRESTClient) ExecutePluginInstanceAction(ctx context.Context, req *apihubpb.ExecutePluginInstanceActionRequest, opts ...gax.CallOption) (*ExecutePluginInstanceActionOperation, error) {
858 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
859 jsonReq, err := m.Marshal(req)
860 if err != nil {
861 return nil, err
862 }
863
864 baseUrl, err := url.Parse(c.endpoint)
865 if err != nil {
866 return nil, err
867 }
868 baseUrl.Path += fmt.Sprintf("/v1/%v:executeAction", req.GetName())
869
870 params := url.Values{}
871 params.Add("$alt", "json;enum-encoding=int")
872
873 baseUrl.RawQuery = params.Encode()
874
875 // Build HTTP headers from client and context metadata.
876 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
877
878 hds = append(c.xGoogHeaders, hds...)
879 hds = append(hds, "Content-Type", "application/json")
880 headers := gax.BuildHeaders(ctx, hds...)
881 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
882 resp := &longrunningpb.Operation{}
883 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
884 if settings.Path != "" {
885 baseUrl.Path = settings.Path
886 }
887 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
888 if err != nil {
889 return err
890 }
891 httpReq = httpReq.WithContext(ctx)
892 httpReq.Header = headers
893
894 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ExecutePluginInstanceAction")
895 if err != nil {
896 return err
897 }
898 if err := unm.Unmarshal(buf, resp); err != nil {
899 return err
900 }
901
902 return nil
903 }, opts...)
904 if e != nil {
905 return nil, e
906 }
907
908 override := fmt.Sprintf("/v1/%s", resp.GetName())
909 return &ExecutePluginInstanceActionOperation{
910 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
911 pollPath: override,
912 }, nil
913 }
914
915 // GetPluginInstance get an API Hub plugin instance.
916 func (c *apiHubPluginRESTClient) GetPluginInstance(ctx context.Context, req *apihubpb.GetPluginInstanceRequest, opts ...gax.CallOption) (*apihubpb.PluginInstance, error) {
917 baseUrl, err := url.Parse(c.endpoint)
918 if err != nil {
919 return nil, err
920 }
921 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
922
923 params := url.Values{}
924 params.Add("$alt", "json;enum-encoding=int")
925
926 baseUrl.RawQuery = params.Encode()
927
928 // Build HTTP headers from client and context metadata.
929 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
930
931 hds = append(c.xGoogHeaders, hds...)
932 hds = append(hds, "Content-Type", "application/json")
933 headers := gax.BuildHeaders(ctx, hds...)
934 opts = append((*c.CallOptions).GetPluginInstance[0:len((*c.CallOptions).GetPluginInstance):len((*c.CallOptions).GetPluginInstance)], opts...)
935 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
936 resp := &apihubpb.PluginInstance{}
937 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
938 if settings.Path != "" {
939 baseUrl.Path = settings.Path
940 }
941 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
942 if err != nil {
943 return err
944 }
945 httpReq = httpReq.WithContext(ctx)
946 httpReq.Header = headers
947
948 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetPluginInstance")
949 if err != nil {
950 return err
951 }
952
953 if err := unm.Unmarshal(buf, resp); err != nil {
954 return err
955 }
956
957 return nil
958 }, opts...)
959 if e != nil {
960 return nil, e
961 }
962 return resp, nil
963 }
964
965 // ListPluginInstances list all the plugins in a given project and location.
966 // - can be used as wildcard value for {plugin_id}
967 func (c *apiHubPluginRESTClient) ListPluginInstances(ctx context.Context, req *apihubpb.ListPluginInstancesRequest, opts ...gax.CallOption) *PluginInstanceIterator {
968 it := &PluginInstanceIterator{}
969 req = proto.Clone(req).(*apihubpb.ListPluginInstancesRequest)
970 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
971 it.InternalFetch = func(pageSize int, pageToken string) ([]*apihubpb.PluginInstance, string, error) {
972 resp := &apihubpb.ListPluginInstancesResponse{}
973 if pageToken != "" {
974 req.PageToken = pageToken
975 }
976 if pageSize > math.MaxInt32 {
977 req.PageSize = math.MaxInt32
978 } else if pageSize != 0 {
979 req.PageSize = int32(pageSize)
980 }
981 baseUrl, err := url.Parse(c.endpoint)
982 if err != nil {
983 return nil, "", err
984 }
985 baseUrl.Path += fmt.Sprintf("/v1/%v/instances", req.GetParent())
986
987 params := url.Values{}
988 params.Add("$alt", "json;enum-encoding=int")
989 if req.GetFilter() != "" {
990 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
991 }
992 if req.GetPageSize() != 0 {
993 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
994 }
995 if req.GetPageToken() != "" {
996 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
997 }
998
999 baseUrl.RawQuery = params.Encode()
1000
1001 // Build HTTP headers from client and context metadata.
1002 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1003 headers := gax.BuildHeaders(ctx, hds...)
1004 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1005 if settings.Path != "" {
1006 baseUrl.Path = settings.Path
1007 }
1008 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1009 if err != nil {
1010 return err
1011 }
1012 httpReq.Header = headers
1013
1014 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListPluginInstances")
1015 if err != nil {
1016 return err
1017 }
1018 if err := unm.Unmarshal(buf, resp); err != nil {
1019 return err
1020 }
1021
1022 return nil
1023 }, opts...)
1024 if e != nil {
1025 return nil, "", e
1026 }
1027 it.Response = resp
1028 return resp.GetPluginInstances(), resp.GetNextPageToken(), nil
1029 }
1030
1031 fetch := func(pageSize int, pageToken string) (string, error) {
1032 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1033 if err != nil {
1034 return "", err
1035 }
1036 it.items = append(it.items, items...)
1037 return nextPageToken, nil
1038 }
1039
1040 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1041 it.pageInfo.MaxSize = int(req.GetPageSize())
1042 it.pageInfo.Token = req.GetPageToken()
1043
1044 return it
1045 }
1046
1047 // EnablePluginInstanceAction enables a plugin instance in the API hub.
1048 func (c *apiHubPluginRESTClient) EnablePluginInstanceAction(ctx context.Context, req *apihubpb.EnablePluginInstanceActionRequest, opts ...gax.CallOption) (*EnablePluginInstanceActionOperation, error) {
1049 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1050 jsonReq, err := m.Marshal(req)
1051 if err != nil {
1052 return nil, err
1053 }
1054
1055 baseUrl, err := url.Parse(c.endpoint)
1056 if err != nil {
1057 return nil, err
1058 }
1059 baseUrl.Path += fmt.Sprintf("/v1/%v:enableAction", req.GetName())
1060
1061 params := url.Values{}
1062 params.Add("$alt", "json;enum-encoding=int")
1063
1064 baseUrl.RawQuery = params.Encode()
1065
1066 // Build HTTP headers from client and context metadata.
1067 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1068
1069 hds = append(c.xGoogHeaders, hds...)
1070 hds = append(hds, "Content-Type", "application/json")
1071 headers := gax.BuildHeaders(ctx, hds...)
1072 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1073 resp := &longrunningpb.Operation{}
1074 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1075 if settings.Path != "" {
1076 baseUrl.Path = settings.Path
1077 }
1078 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1079 if err != nil {
1080 return err
1081 }
1082 httpReq = httpReq.WithContext(ctx)
1083 httpReq.Header = headers
1084
1085 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "EnablePluginInstanceAction")
1086 if err != nil {
1087 return err
1088 }
1089 if err := unm.Unmarshal(buf, resp); err != nil {
1090 return err
1091 }
1092
1093 return nil
1094 }, opts...)
1095 if e != nil {
1096 return nil, e
1097 }
1098
1099 override := fmt.Sprintf("/v1/%s", resp.GetName())
1100 return &EnablePluginInstanceActionOperation{
1101 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1102 pollPath: override,
1103 }, nil
1104 }
1105
1106 // DisablePluginInstanceAction disables a plugin instance in the API hub.
1107 func (c *apiHubPluginRESTClient) DisablePluginInstanceAction(ctx context.Context, req *apihubpb.DisablePluginInstanceActionRequest, opts ...gax.CallOption) (*DisablePluginInstanceActionOperation, error) {
1108 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1109 jsonReq, err := m.Marshal(req)
1110 if err != nil {
1111 return nil, err
1112 }
1113
1114 baseUrl, err := url.Parse(c.endpoint)
1115 if err != nil {
1116 return nil, err
1117 }
1118 baseUrl.Path += fmt.Sprintf("/v1/%v:disableAction", req.GetName())
1119
1120 params := url.Values{}
1121 params.Add("$alt", "json;enum-encoding=int")
1122
1123 baseUrl.RawQuery = params.Encode()
1124
1125 // Build HTTP headers from client and context metadata.
1126 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1127
1128 hds = append(c.xGoogHeaders, hds...)
1129 hds = append(hds, "Content-Type", "application/json")
1130 headers := gax.BuildHeaders(ctx, hds...)
1131 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1132 resp := &longrunningpb.Operation{}
1133 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1134 if settings.Path != "" {
1135 baseUrl.Path = settings.Path
1136 }
1137 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1138 if err != nil {
1139 return err
1140 }
1141 httpReq = httpReq.WithContext(ctx)
1142 httpReq.Header = headers
1143
1144 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "DisablePluginInstanceAction")
1145 if err != nil {
1146 return err
1147 }
1148 if err := unm.Unmarshal(buf, resp); err != nil {
1149 return err
1150 }
1151
1152 return nil
1153 }, opts...)
1154 if e != nil {
1155 return nil, e
1156 }
1157
1158 override := fmt.Sprintf("/v1/%s", resp.GetName())
1159 return &DisablePluginInstanceActionOperation{
1160 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1161 pollPath: override,
1162 }, nil
1163 }
1164
1165 // UpdatePluginInstance updates a plugin instance in the API hub.
1166 // The following fields in the
1167 // plugin_instance can be updated
1168 // currently:
1169 //
1170 // display_name
1171 //
1172 // schedule_cron_expression
1173 //
1174 // The
1175 // update_mask
1176 // should be used to specify the fields being updated.
1177 //
1178 // To update the
1179 // auth_config and
1180 // additional_config
1181 // of the plugin instance, use the
1182 // ApplyPluginInstanceConfig
1183 // method.
1184 func (c *apiHubPluginRESTClient) UpdatePluginInstance(ctx context.Context, req *apihubpb.UpdatePluginInstanceRequest, opts ...gax.CallOption) (*apihubpb.PluginInstance, error) {
1185 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1186 body := req.GetPluginInstance()
1187 jsonReq, err := m.Marshal(body)
1188 if err != nil {
1189 return nil, err
1190 }
1191
1192 baseUrl, err := url.Parse(c.endpoint)
1193 if err != nil {
1194 return nil, err
1195 }
1196 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetPluginInstance().GetName())
1197
1198 params := url.Values{}
1199 params.Add("$alt", "json;enum-encoding=int")
1200 if req.GetUpdateMask() != nil {
1201 field, err := protojson.Marshal(req.GetUpdateMask())
1202 if err != nil {
1203 return nil, err
1204 }
1205 params.Add("updateMask", string(field[1:len(field)-1]))
1206 }
1207
1208 baseUrl.RawQuery = params.Encode()
1209
1210 // Build HTTP headers from client and context metadata.
1211 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "plugin_instance.name", url.QueryEscape(req.GetPluginInstance().GetName()))}
1212
1213 hds = append(c.xGoogHeaders, hds...)
1214 hds = append(hds, "Content-Type", "application/json")
1215 headers := gax.BuildHeaders(ctx, hds...)
1216 opts = append((*c.CallOptions).UpdatePluginInstance[0:len((*c.CallOptions).UpdatePluginInstance):len((*c.CallOptions).UpdatePluginInstance)], opts...)
1217 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1218 resp := &apihubpb.PluginInstance{}
1219 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1220 if settings.Path != "" {
1221 baseUrl.Path = settings.Path
1222 }
1223 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1224 if err != nil {
1225 return err
1226 }
1227 httpReq = httpReq.WithContext(ctx)
1228 httpReq.Header = headers
1229
1230 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdatePluginInstance")
1231 if err != nil {
1232 return err
1233 }
1234
1235 if err := unm.Unmarshal(buf, resp); err != nil {
1236 return err
1237 }
1238
1239 return nil
1240 }, opts...)
1241 if e != nil {
1242 return nil, e
1243 }
1244 return resp, nil
1245 }
1246
1247 // DeletePluginInstance deletes a plugin instance in the API hub.
1248 func (c *apiHubPluginRESTClient) DeletePluginInstance(ctx context.Context, req *apihubpb.DeletePluginInstanceRequest, opts ...gax.CallOption) (*DeletePluginInstanceOperation, error) {
1249 baseUrl, err := url.Parse(c.endpoint)
1250 if err != nil {
1251 return nil, err
1252 }
1253 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1254
1255 params := url.Values{}
1256 params.Add("$alt", "json;enum-encoding=int")
1257
1258 baseUrl.RawQuery = params.Encode()
1259
1260 // Build HTTP headers from client and context metadata.
1261 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1262
1263 hds = append(c.xGoogHeaders, hds...)
1264 hds = append(hds, "Content-Type", "application/json")
1265 headers := gax.BuildHeaders(ctx, hds...)
1266 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1267 resp := &longrunningpb.Operation{}
1268 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1269 if settings.Path != "" {
1270 baseUrl.Path = settings.Path
1271 }
1272 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1273 if err != nil {
1274 return err
1275 }
1276 httpReq = httpReq.WithContext(ctx)
1277 httpReq.Header = headers
1278
1279 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeletePluginInstance")
1280 if err != nil {
1281 return err
1282 }
1283 if err := unm.Unmarshal(buf, resp); err != nil {
1284 return err
1285 }
1286
1287 return nil
1288 }, opts...)
1289 if e != nil {
1290 return nil, e
1291 }
1292
1293 override := fmt.Sprintf("/v1/%s", resp.GetName())
1294 return &DeletePluginInstanceOperation{
1295 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1296 pollPath: override,
1297 }, nil
1298 }
1299
1300 // GetLocation gets information about a location.
1301 func (c *apiHubPluginRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
1302 baseUrl, err := url.Parse(c.endpoint)
1303 if err != nil {
1304 return nil, err
1305 }
1306 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1307
1308 params := url.Values{}
1309 params.Add("$alt", "json;enum-encoding=int")
1310
1311 baseUrl.RawQuery = params.Encode()
1312
1313 // Build HTTP headers from client and context metadata.
1314 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1315
1316 hds = append(c.xGoogHeaders, hds...)
1317 hds = append(hds, "Content-Type", "application/json")
1318 headers := gax.BuildHeaders(ctx, hds...)
1319 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
1320 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1321 resp := &locationpb.Location{}
1322 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1323 if settings.Path != "" {
1324 baseUrl.Path = settings.Path
1325 }
1326 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1327 if err != nil {
1328 return err
1329 }
1330 httpReq = httpReq.WithContext(ctx)
1331 httpReq.Header = headers
1332
1333 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
1334 if err != nil {
1335 return err
1336 }
1337
1338 if err := unm.Unmarshal(buf, resp); err != nil {
1339 return err
1340 }
1341
1342 return nil
1343 }, opts...)
1344 if e != nil {
1345 return nil, e
1346 }
1347 return resp, nil
1348 }
1349
1350 // ListLocations lists information about the supported locations for this service.
1351 func (c *apiHubPluginRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
1352 it := &LocationIterator{}
1353 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
1354 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1355 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
1356 resp := &locationpb.ListLocationsResponse{}
1357 if pageToken != "" {
1358 req.PageToken = pageToken
1359 }
1360 if pageSize > math.MaxInt32 {
1361 req.PageSize = math.MaxInt32
1362 } else if pageSize != 0 {
1363 req.PageSize = int32(pageSize)
1364 }
1365 baseUrl, err := url.Parse(c.endpoint)
1366 if err != nil {
1367 return nil, "", err
1368 }
1369 baseUrl.Path += fmt.Sprintf("/v1/%v/locations", req.GetName())
1370
1371 params := url.Values{}
1372 params.Add("$alt", "json;enum-encoding=int")
1373 if req.GetFilter() != "" {
1374 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1375 }
1376 if req.GetPageSize() != 0 {
1377 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1378 }
1379 if req.GetPageToken() != "" {
1380 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1381 }
1382
1383 baseUrl.RawQuery = params.Encode()
1384
1385 // Build HTTP headers from client and context metadata.
1386 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1387 headers := gax.BuildHeaders(ctx, hds...)
1388 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1389 if settings.Path != "" {
1390 baseUrl.Path = settings.Path
1391 }
1392 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1393 if err != nil {
1394 return err
1395 }
1396 httpReq.Header = headers
1397
1398 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
1399 if err != nil {
1400 return err
1401 }
1402 if err := unm.Unmarshal(buf, resp); err != nil {
1403 return err
1404 }
1405
1406 return nil
1407 }, opts...)
1408 if e != nil {
1409 return nil, "", e
1410 }
1411 it.Response = resp
1412 return resp.GetLocations(), resp.GetNextPageToken(), nil
1413 }
1414
1415 fetch := func(pageSize int, pageToken string) (string, error) {
1416 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1417 if err != nil {
1418 return "", err
1419 }
1420 it.items = append(it.items, items...)
1421 return nextPageToken, nil
1422 }
1423
1424 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1425 it.pageInfo.MaxSize = int(req.GetPageSize())
1426 it.pageInfo.Token = req.GetPageToken()
1427
1428 return it
1429 }
1430
1431 // CancelOperation is a utility method from google.longrunning.Operations.
1432 func (c *apiHubPluginRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
1433 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1434 jsonReq, err := m.Marshal(req)
1435 if err != nil {
1436 return err
1437 }
1438
1439 baseUrl, err := url.Parse(c.endpoint)
1440 if err != nil {
1441 return err
1442 }
1443 baseUrl.Path += fmt.Sprintf("/v1/%v:cancel", req.GetName())
1444
1445 params := url.Values{}
1446 params.Add("$alt", "json;enum-encoding=int")
1447
1448 baseUrl.RawQuery = params.Encode()
1449
1450 // Build HTTP headers from client and context metadata.
1451 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1452
1453 hds = append(c.xGoogHeaders, hds...)
1454 hds = append(hds, "Content-Type", "application/json")
1455 headers := gax.BuildHeaders(ctx, hds...)
1456 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1457 if settings.Path != "" {
1458 baseUrl.Path = settings.Path
1459 }
1460 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1461 if err != nil {
1462 return err
1463 }
1464 httpReq = httpReq.WithContext(ctx)
1465 httpReq.Header = headers
1466
1467 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelOperation")
1468 return err
1469 }, opts...)
1470 }
1471
1472 // DeleteOperation is a utility method from google.longrunning.Operations.
1473 func (c *apiHubPluginRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
1474 baseUrl, err := url.Parse(c.endpoint)
1475 if err != nil {
1476 return err
1477 }
1478 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1479
1480 params := url.Values{}
1481 params.Add("$alt", "json;enum-encoding=int")
1482
1483 baseUrl.RawQuery = params.Encode()
1484
1485 // Build HTTP headers from client and context metadata.
1486 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1487
1488 hds = append(c.xGoogHeaders, hds...)
1489 hds = append(hds, "Content-Type", "application/json")
1490 headers := gax.BuildHeaders(ctx, hds...)
1491 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1492 if settings.Path != "" {
1493 baseUrl.Path = settings.Path
1494 }
1495 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1496 if err != nil {
1497 return err
1498 }
1499 httpReq = httpReq.WithContext(ctx)
1500 httpReq.Header = headers
1501
1502 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
1503 return err
1504 }, opts...)
1505 }
1506
1507 // GetOperation is a utility method from google.longrunning.Operations.
1508 func (c *apiHubPluginRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
1509 baseUrl, err := url.Parse(c.endpoint)
1510 if err != nil {
1511 return nil, err
1512 }
1513 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1514
1515 params := url.Values{}
1516 params.Add("$alt", "json;enum-encoding=int")
1517
1518 baseUrl.RawQuery = params.Encode()
1519
1520 // Build HTTP headers from client and context metadata.
1521 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1522
1523 hds = append(c.xGoogHeaders, hds...)
1524 hds = append(hds, "Content-Type", "application/json")
1525 headers := gax.BuildHeaders(ctx, hds...)
1526 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
1527 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1528 resp := &longrunningpb.Operation{}
1529 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1530 if settings.Path != "" {
1531 baseUrl.Path = settings.Path
1532 }
1533 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1534 if err != nil {
1535 return err
1536 }
1537 httpReq = httpReq.WithContext(ctx)
1538 httpReq.Header = headers
1539
1540 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
1541 if err != nil {
1542 return err
1543 }
1544
1545 if err := unm.Unmarshal(buf, resp); err != nil {
1546 return err
1547 }
1548
1549 return nil
1550 }, opts...)
1551 if e != nil {
1552 return nil, e
1553 }
1554 return resp, nil
1555 }
1556
1557 // ListOperations is a utility method from google.longrunning.Operations.
1558 func (c *apiHubPluginRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
1559 it := &OperationIterator{}
1560 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
1561 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1562 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
1563 resp := &longrunningpb.ListOperationsResponse{}
1564 if pageToken != "" {
1565 req.PageToken = pageToken
1566 }
1567 if pageSize > math.MaxInt32 {
1568 req.PageSize = math.MaxInt32
1569 } else if pageSize != 0 {
1570 req.PageSize = int32(pageSize)
1571 }
1572 baseUrl, err := url.Parse(c.endpoint)
1573 if err != nil {
1574 return nil, "", err
1575 }
1576 baseUrl.Path += fmt.Sprintf("/v1/%v/operations", req.GetName())
1577
1578 params := url.Values{}
1579 params.Add("$alt", "json;enum-encoding=int")
1580 if req.GetFilter() != "" {
1581 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1582 }
1583 if req.GetPageSize() != 0 {
1584 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1585 }
1586 if req.GetPageToken() != "" {
1587 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1588 }
1589
1590 baseUrl.RawQuery = params.Encode()
1591
1592 // Build HTTP headers from client and context metadata.
1593 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1594 headers := gax.BuildHeaders(ctx, hds...)
1595 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1596 if settings.Path != "" {
1597 baseUrl.Path = settings.Path
1598 }
1599 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1600 if err != nil {
1601 return err
1602 }
1603 httpReq.Header = headers
1604
1605 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
1606 if err != nil {
1607 return err
1608 }
1609 if err := unm.Unmarshal(buf, resp); err != nil {
1610 return err
1611 }
1612
1613 return nil
1614 }, opts...)
1615 if e != nil {
1616 return nil, "", e
1617 }
1618 it.Response = resp
1619 return resp.GetOperations(), resp.GetNextPageToken(), nil
1620 }
1621
1622 fetch := func(pageSize int, pageToken string) (string, error) {
1623 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1624 if err != nil {
1625 return "", err
1626 }
1627 it.items = append(it.items, items...)
1628 return nextPageToken, nil
1629 }
1630
1631 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1632 it.pageInfo.MaxSize = int(req.GetPageSize())
1633 it.pageInfo.Token = req.GetPageToken()
1634
1635 return it
1636 }
1637
1638 // CreatePluginInstanceOperation returns a new CreatePluginInstanceOperation from a given name.
1639 // The name must be that of a previously created CreatePluginInstanceOperation, possibly from a different process.
1640 func (c *apiHubPluginRESTClient) CreatePluginInstanceOperation(name string) *CreatePluginInstanceOperation {
1641 override := fmt.Sprintf("/v1/%s", name)
1642 return &CreatePluginInstanceOperation{
1643 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1644 pollPath: override,
1645 }
1646 }
1647
1648 // DeletePluginOperation returns a new DeletePluginOperation from a given name.
1649 // The name must be that of a previously created DeletePluginOperation, possibly from a different process.
1650 func (c *apiHubPluginRESTClient) DeletePluginOperation(name string) *DeletePluginOperation {
1651 override := fmt.Sprintf("/v1/%s", name)
1652 return &DeletePluginOperation{
1653 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1654 pollPath: override,
1655 }
1656 }
1657
1658 // DeletePluginInstanceOperation returns a new DeletePluginInstanceOperation from a given name.
1659 // The name must be that of a previously created DeletePluginInstanceOperation, possibly from a different process.
1660 func (c *apiHubPluginRESTClient) DeletePluginInstanceOperation(name string) *DeletePluginInstanceOperation {
1661 override := fmt.Sprintf("/v1/%s", name)
1662 return &DeletePluginInstanceOperation{
1663 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1664 pollPath: override,
1665 }
1666 }
1667
1668 // DisablePluginInstanceActionOperation returns a new DisablePluginInstanceActionOperation from a given name.
1669 // The name must be that of a previously created DisablePluginInstanceActionOperation, possibly from a different process.
1670 func (c *apiHubPluginRESTClient) DisablePluginInstanceActionOperation(name string) *DisablePluginInstanceActionOperation {
1671 override := fmt.Sprintf("/v1/%s", name)
1672 return &DisablePluginInstanceActionOperation{
1673 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1674 pollPath: override,
1675 }
1676 }
1677
1678 // EnablePluginInstanceActionOperation returns a new EnablePluginInstanceActionOperation from a given name.
1679 // The name must be that of a previously created EnablePluginInstanceActionOperation, possibly from a different process.
1680 func (c *apiHubPluginRESTClient) EnablePluginInstanceActionOperation(name string) *EnablePluginInstanceActionOperation {
1681 override := fmt.Sprintf("/v1/%s", name)
1682 return &EnablePluginInstanceActionOperation{
1683 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1684 pollPath: override,
1685 }
1686 }
1687
1688 // ExecutePluginInstanceActionOperation returns a new ExecutePluginInstanceActionOperation from a given name.
1689 // The name must be that of a previously created ExecutePluginInstanceActionOperation, possibly from a different process.
1690 func (c *apiHubPluginRESTClient) ExecutePluginInstanceActionOperation(name string) *ExecutePluginInstanceActionOperation {
1691 override := fmt.Sprintf("/v1/%s", name)
1692 return &ExecutePluginInstanceActionOperation{
1693 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1694 pollPath: override,
1695 }
1696 }