...

Source file src/google.golang.org/api/workflowexecutions/v1beta/workflowexecutions-gen.go

Documentation: google.golang.org/api/workflowexecutions/v1beta

     1  // Copyright 2024 Google LLC.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Code generated file. DO NOT EDIT.
     6  
     7  // Package workflowexecutions provides access to the Workflow Executions API.
     8  //
     9  // For product documentation, see: https://cloud.google.com/workflows
    10  //
    11  // # Library status
    12  //
    13  // These client libraries are officially supported by Google. However, this
    14  // library is considered complete and is in maintenance mode. This means
    15  // that we will address critical bugs and security issues but will not add
    16  // any new features.
    17  //
    18  // When possible, we recommend using our newer
    19  // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
    20  // that are still actively being worked and iterated on.
    21  //
    22  // # Creating a client
    23  //
    24  // Usage example:
    25  //
    26  //	import "google.golang.org/api/workflowexecutions/v1beta"
    27  //	...
    28  //	ctx := context.Background()
    29  //	workflowexecutionsService, err := workflowexecutions.NewService(ctx)
    30  //
    31  // In this example, Google Application Default Credentials are used for
    32  // authentication. For information on how to create and obtain Application
    33  // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
    34  //
    35  // # Other authentication options
    36  //
    37  // To use an API key for authentication (note: some APIs do not support API
    38  // keys), use [google.golang.org/api/option.WithAPIKey]:
    39  //
    40  //	workflowexecutionsService, err := workflowexecutions.NewService(ctx, option.WithAPIKey("AIza..."))
    41  //
    42  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    43  // flow, use [google.golang.org/api/option.WithTokenSource]:
    44  //
    45  //	config := &oauth2.Config{...}
    46  //	// ...
    47  //	token, err := config.Exchange(ctx, ...)
    48  //	workflowexecutionsService, err := workflowexecutions.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    49  //
    50  // See [google.golang.org/api/option.ClientOption] for details on options.
    51  package workflowexecutions // import "google.golang.org/api/workflowexecutions/v1beta"
    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  // Always reference these packages, just in case the auto-generated code
    74  // below doesn't.
    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 = "workflowexecutions:v1beta"
    90  const apiName = "workflowexecutions"
    91  const apiVersion = "v1beta"
    92  const basePath = "https://workflowexecutions.googleapis.com/"
    93  const basePathTemplate = "https://workflowexecutions.UNIVERSE_DOMAIN/"
    94  const mtlsBasePath = "https://workflowexecutions.mtls.googleapis.com/"
    95  
    96  // OAuth2 scopes used by this API.
    97  const (
    98  	// See, edit, configure, and delete your Google Cloud data and see the email
    99  	// address for your Google Account.
   100  	CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
   101  )
   102  
   103  // NewService creates a new Service.
   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  	// NOTE: prepend, so we don't override user-specified scopes.
   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  // New creates a new Service. It uses the provided http.Client for requests.
   129  //
   130  // Deprecated: please use NewService instead.
   131  // To provide a custom HTTP client, use option.WithHTTPClient.
   132  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   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 // API endpoint base URL
   145  	UserAgent string // optional additional User-Agent fragment
   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.Workflows = NewProjectsLocationsWorkflowsService(s)
   172  	return rs
   173  }
   174  
   175  type ProjectsLocationsService struct {
   176  	s *Service
   177  
   178  	Workflows *ProjectsLocationsWorkflowsService
   179  }
   180  
   181  func NewProjectsLocationsWorkflowsService(s *Service) *ProjectsLocationsWorkflowsService {
   182  	rs := &ProjectsLocationsWorkflowsService{s: s}
   183  	rs.Executions = NewProjectsLocationsWorkflowsExecutionsService(s)
   184  	return rs
   185  }
   186  
   187  type ProjectsLocationsWorkflowsService struct {
   188  	s *Service
   189  
   190  	Executions *ProjectsLocationsWorkflowsExecutionsService
   191  }
   192  
   193  func NewProjectsLocationsWorkflowsExecutionsService(s *Service) *ProjectsLocationsWorkflowsExecutionsService {
   194  	rs := &ProjectsLocationsWorkflowsExecutionsService{s: s}
   195  	return rs
   196  }
   197  
   198  type ProjectsLocationsWorkflowsExecutionsService struct {
   199  	s *Service
   200  }
   201  
   202  // CancelExecutionRequest: Request for the CancelExecution method.
   203  type CancelExecutionRequest struct {
   204  }
   205  
   206  // Error: Error describes why the execution was abnormally terminated.
   207  type Error struct {
   208  	// Context: Human-readable stack trace string.
   209  	Context string `json:"context,omitempty"`
   210  	// Payload: Error message and data returned represented as a JSON string.
   211  	Payload string `json:"payload,omitempty"`
   212  	// StackTrace: Stack trace with detailed information of where error was
   213  	// generated.
   214  	StackTrace *StackTrace `json:"stackTrace,omitempty"`
   215  	// ForceSendFields is a list of field names (e.g. "Context") to unconditionally
   216  	// include in API requests. By default, fields with empty or default values are
   217  	// omitted from API requests. See
   218  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   219  	// details.
   220  	ForceSendFields []string `json:"-"`
   221  	// NullFields is a list of field names (e.g. "Context") to include in API
   222  	// requests with the JSON null value. By default, fields with empty values are
   223  	// omitted from API requests. See
   224  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   225  	NullFields []string `json:"-"`
   226  }
   227  
   228  func (s *Error) MarshalJSON() ([]byte, error) {
   229  	type NoMethod Error
   230  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   231  }
   232  
   233  // Execution: A running instance of a Workflow
   234  // (/workflows/docs/reference/rest/v1beta/projects.locations.workflows).
   235  type Execution struct {
   236  	// Argument: Input parameters of the execution represented as a JSON string.
   237  	// The size limit is 32KB. *Note*: If you are using the REST API directly to
   238  	// run your workflow, you must escape any JSON string value of `argument`.
   239  	// Example: `'{"argument":"{\"firstName\":\"FIRST\",\"lastName\":\"LAST\"}"}'`
   240  	Argument string `json:"argument,omitempty"`
   241  	// CallLogLevel: The call logging level associated to this execution.
   242  	//
   243  	// Possible values:
   244  	//   "CALL_LOG_LEVEL_UNSPECIFIED" - No call logging level specified.
   245  	//   "LOG_ALL_CALLS" - Log all call steps within workflows, all call returns,
   246  	// and all exceptions raised.
   247  	//   "LOG_ERRORS_ONLY" - Log only exceptions that are raised from call steps
   248  	// within workflows.
   249  	CallLogLevel string `json:"callLogLevel,omitempty"`
   250  	// EndTime: Output only. Marks the end of execution, successful or not.
   251  	EndTime string `json:"endTime,omitempty"`
   252  	// Error: Output only. The error which caused the execution to finish
   253  	// prematurely. The value is only present if the execution's state is `FAILED`
   254  	// or `CANCELLED`.
   255  	Error *Error `json:"error,omitempty"`
   256  	// Name: Output only. The resource name of the execution. Format:
   257  	// projects/{project}/locations/{location}/workflows/{workflow}/executions/{exec
   258  	// ution}
   259  	Name string `json:"name,omitempty"`
   260  	// Result: Output only. Output of the execution represented as a JSON string.
   261  	// The value can only be present if the execution's state is `SUCCEEDED`.
   262  	Result string `json:"result,omitempty"`
   263  	// StartTime: Output only. Marks the beginning of execution.
   264  	StartTime string `json:"startTime,omitempty"`
   265  	// State: Output only. Current state of the execution.
   266  	//
   267  	// Possible values:
   268  	//   "STATE_UNSPECIFIED" - Invalid state.
   269  	//   "ACTIVE" - The execution is in progress.
   270  	//   "SUCCEEDED" - The execution finished successfully.
   271  	//   "FAILED" - The execution failed with an error.
   272  	//   "CANCELLED" - The execution was stopped intentionally.
   273  	//   "UNAVAILABLE" - Reserved for future use.
   274  	//   "QUEUED" - Request has been placed in the backlog for processing at a
   275  	// later time.
   276  	State string `json:"state,omitempty"`
   277  	// Status: Output only. Status tracks the current steps and progress data of
   278  	// this execution.
   279  	Status *Status `json:"status,omitempty"`
   280  	// WorkflowRevisionId: Output only. Revision of the workflow this execution is
   281  	// using.
   282  	WorkflowRevisionId string `json:"workflowRevisionId,omitempty"`
   283  
   284  	// ServerResponse contains the HTTP response code and headers from the server.
   285  	googleapi.ServerResponse `json:"-"`
   286  	// ForceSendFields is a list of field names (e.g. "Argument") to
   287  	// unconditionally include in API requests. By default, fields with empty or
   288  	// default values are omitted from API requests. See
   289  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   290  	// details.
   291  	ForceSendFields []string `json:"-"`
   292  	// NullFields is a list of field names (e.g. "Argument") to include in API
   293  	// requests with the JSON null value. By default, fields with empty values are
   294  	// omitted from API requests. See
   295  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   296  	NullFields []string `json:"-"`
   297  }
   298  
   299  func (s *Execution) MarshalJSON() ([]byte, error) {
   300  	type NoMethod Execution
   301  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   302  }
   303  
   304  // ListExecutionsResponse: Response for the ListExecutions method.
   305  type ListExecutionsResponse struct {
   306  	// Executions: The executions which match the request.
   307  	Executions []*Execution `json:"executions,omitempty"`
   308  	// NextPageToken: A token, which can be sent as `page_token` to retrieve the
   309  	// next page. If this field is omitted, there are no subsequent pages.
   310  	NextPageToken string `json:"nextPageToken,omitempty"`
   311  
   312  	// ServerResponse contains the HTTP response code and headers from the server.
   313  	googleapi.ServerResponse `json:"-"`
   314  	// ForceSendFields is a list of field names (e.g. "Executions") to
   315  	// unconditionally include in API requests. By default, fields with empty or
   316  	// default values are omitted from API requests. See
   317  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   318  	// details.
   319  	ForceSendFields []string `json:"-"`
   320  	// NullFields is a list of field names (e.g. "Executions") to include in API
   321  	// requests with the JSON null value. By default, fields with empty values are
   322  	// omitted from API requests. See
   323  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   324  	NullFields []string `json:"-"`
   325  }
   326  
   327  func (s *ListExecutionsResponse) MarshalJSON() ([]byte, error) {
   328  	type NoMethod ListExecutionsResponse
   329  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   330  }
   331  
   332  // Position: Position contains source position information about the stack
   333  // trace element such as line number, column number and length of the code
   334  // block in bytes.
   335  type Position struct {
   336  	// Column: The source code column position (of the line) the current
   337  	// instruction was generated from.
   338  	Column int64 `json:"column,omitempty,string"`
   339  	// Length: The number of bytes of source code making up this stack trace
   340  	// element.
   341  	Length int64 `json:"length,omitempty,string"`
   342  	// Line: The source code line number the current instruction was generated
   343  	// from.
   344  	Line int64 `json:"line,omitempty,string"`
   345  	// ForceSendFields is a list of field names (e.g. "Column") to unconditionally
   346  	// include in API requests. By default, fields with empty or default values are
   347  	// omitted from API requests. See
   348  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   349  	// details.
   350  	ForceSendFields []string `json:"-"`
   351  	// NullFields is a list of field names (e.g. "Column") to include in API
   352  	// requests with the JSON null value. By default, fields with empty values are
   353  	// omitted from API requests. See
   354  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   355  	NullFields []string `json:"-"`
   356  }
   357  
   358  func (s *Position) MarshalJSON() ([]byte, error) {
   359  	type NoMethod Position
   360  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   361  }
   362  
   363  // StackTrace: A collection of stack elements (frames) where an error occurred.
   364  type StackTrace struct {
   365  	// Elements: An array of stack elements.
   366  	Elements []*StackTraceElement `json:"elements,omitempty"`
   367  	// ForceSendFields is a list of field names (e.g. "Elements") to
   368  	// unconditionally include in API requests. By default, fields with empty or
   369  	// default values are omitted from API requests. See
   370  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   371  	// details.
   372  	ForceSendFields []string `json:"-"`
   373  	// NullFields is a list of field names (e.g. "Elements") to include in API
   374  	// requests with the JSON null value. By default, fields with empty values are
   375  	// omitted from API requests. See
   376  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   377  	NullFields []string `json:"-"`
   378  }
   379  
   380  func (s *StackTrace) MarshalJSON() ([]byte, error) {
   381  	type NoMethod StackTrace
   382  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   383  }
   384  
   385  // StackTraceElement: A single stack element (frame) where an error occurred.
   386  type StackTraceElement struct {
   387  	// Position: The source position information of the stack trace element.
   388  	Position *Position `json:"position,omitempty"`
   389  	// Routine: The routine where the error occurred.
   390  	Routine string `json:"routine,omitempty"`
   391  	// Step: The step the error occurred at.
   392  	Step string `json:"step,omitempty"`
   393  	// ForceSendFields is a list of field names (e.g. "Position") to
   394  	// unconditionally include in API requests. By default, fields with empty or
   395  	// default values are omitted from API requests. See
   396  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   397  	// details.
   398  	ForceSendFields []string `json:"-"`
   399  	// NullFields is a list of field names (e.g. "Position") to include in API
   400  	// requests with the JSON null value. By default, fields with empty values are
   401  	// omitted from API requests. See
   402  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   403  	NullFields []string `json:"-"`
   404  }
   405  
   406  func (s *StackTraceElement) MarshalJSON() ([]byte, error) {
   407  	type NoMethod StackTraceElement
   408  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   409  }
   410  
   411  // Status: Represents the current status of this execution.
   412  type Status struct {
   413  	// CurrentSteps: A list of currently executing or last executed step names for
   414  	// the workflow execution currently running. If the workflow has succeeded or
   415  	// failed, this is the last attempted or executed step. Presently, if the
   416  	// current step is inside a subworkflow, the list only includes that step. In
   417  	// the future, the list will contain items for each step in the call stack,
   418  	// starting with the outermost step in the `main` subworkflow, and ending with
   419  	// the most deeply nested step.
   420  	CurrentSteps []*Step `json:"currentSteps,omitempty"`
   421  	// ForceSendFields is a list of field names (e.g. "CurrentSteps") to
   422  	// unconditionally include in API requests. By default, fields with empty or
   423  	// default values are omitted from API requests. See
   424  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   425  	// details.
   426  	ForceSendFields []string `json:"-"`
   427  	// NullFields is a list of field names (e.g. "CurrentSteps") to include in API
   428  	// requests with the JSON null value. By default, fields with empty values are
   429  	// omitted from API requests. See
   430  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   431  	NullFields []string `json:"-"`
   432  }
   433  
   434  func (s *Status) MarshalJSON() ([]byte, error) {
   435  	type NoMethod Status
   436  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   437  }
   438  
   439  // Step: Represents a step of the workflow this execution is running.
   440  type Step struct {
   441  	// Routine: Name of a routine within the workflow.
   442  	Routine string `json:"routine,omitempty"`
   443  	// Step: Name of a step within the routine.
   444  	Step string `json:"step,omitempty"`
   445  	// ForceSendFields is a list of field names (e.g. "Routine") to unconditionally
   446  	// include in API requests. By default, fields with empty or default values are
   447  	// omitted from API requests. See
   448  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   449  	// details.
   450  	ForceSendFields []string `json:"-"`
   451  	// NullFields is a list of field names (e.g. "Routine") to include in API
   452  	// requests with the JSON null value. By default, fields with empty values are
   453  	// omitted from API requests. See
   454  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   455  	NullFields []string `json:"-"`
   456  }
   457  
   458  func (s *Step) MarshalJSON() ([]byte, error) {
   459  	type NoMethod Step
   460  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   461  }
   462  
   463  type ProjectsLocationsWorkflowsExecutionsCancelCall struct {
   464  	s                      *Service
   465  	name                   string
   466  	cancelexecutionrequest *CancelExecutionRequest
   467  	urlParams_             gensupport.URLParams
   468  	ctx_                   context.Context
   469  	header_                http.Header
   470  }
   471  
   472  // Cancel: Cancels an execution of the given name.
   473  //
   474  //   - name: Name of the execution to be cancelled. Format:
   475  //     projects/{project}/locations/{location}/workflows/{workflow}/executions/{ex
   476  //     ecution}.
   477  func (r *ProjectsLocationsWorkflowsExecutionsService) Cancel(name string, cancelexecutionrequest *CancelExecutionRequest) *ProjectsLocationsWorkflowsExecutionsCancelCall {
   478  	c := &ProjectsLocationsWorkflowsExecutionsCancelCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   479  	c.name = name
   480  	c.cancelexecutionrequest = cancelexecutionrequest
   481  	return c
   482  }
   483  
   484  // Fields allows partial responses to be retrieved. See
   485  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   486  // details.
   487  func (c *ProjectsLocationsWorkflowsExecutionsCancelCall) Fields(s ...googleapi.Field) *ProjectsLocationsWorkflowsExecutionsCancelCall {
   488  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   489  	return c
   490  }
   491  
   492  // Context sets the context to be used in this call's Do method.
   493  func (c *ProjectsLocationsWorkflowsExecutionsCancelCall) Context(ctx context.Context) *ProjectsLocationsWorkflowsExecutionsCancelCall {
   494  	c.ctx_ = ctx
   495  	return c
   496  }
   497  
   498  // Header returns a http.Header that can be modified by the caller to add
   499  // headers to the request.
   500  func (c *ProjectsLocationsWorkflowsExecutionsCancelCall) Header() http.Header {
   501  	if c.header_ == nil {
   502  		c.header_ = make(http.Header)
   503  	}
   504  	return c.header_
   505  }
   506  
   507  func (c *ProjectsLocationsWorkflowsExecutionsCancelCall) doRequest(alt string) (*http.Response, error) {
   508  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   509  	var body io.Reader = nil
   510  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.cancelexecutionrequest)
   511  	if err != nil {
   512  		return nil, err
   513  	}
   514  	c.urlParams_.Set("alt", alt)
   515  	c.urlParams_.Set("prettyPrint", "false")
   516  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}:cancel")
   517  	urls += "?" + c.urlParams_.Encode()
   518  	req, err := http.NewRequest("POST", urls, body)
   519  	if err != nil {
   520  		return nil, err
   521  	}
   522  	req.Header = reqHeaders
   523  	googleapi.Expand(req.URL, map[string]string{
   524  		"name": c.name,
   525  	})
   526  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   527  }
   528  
   529  // Do executes the "workflowexecutions.projects.locations.workflows.executions.cancel" call.
   530  // Any non-2xx status code is an error. Response headers are in either
   531  // *Execution.ServerResponse.Header or (if a response was returned at all) in
   532  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   533  // whether the returned error was because http.StatusNotModified was returned.
   534  func (c *ProjectsLocationsWorkflowsExecutionsCancelCall) Do(opts ...googleapi.CallOption) (*Execution, error) {
   535  	gensupport.SetOptions(c.urlParams_, opts...)
   536  	res, err := c.doRequest("json")
   537  	if res != nil && res.StatusCode == http.StatusNotModified {
   538  		if res.Body != nil {
   539  			res.Body.Close()
   540  		}
   541  		return nil, gensupport.WrapError(&googleapi.Error{
   542  			Code:   res.StatusCode,
   543  			Header: res.Header,
   544  		})
   545  	}
   546  	if err != nil {
   547  		return nil, err
   548  	}
   549  	defer googleapi.CloseBody(res)
   550  	if err := googleapi.CheckResponse(res); err != nil {
   551  		return nil, gensupport.WrapError(err)
   552  	}
   553  	ret := &Execution{
   554  		ServerResponse: googleapi.ServerResponse{
   555  			Header:         res.Header,
   556  			HTTPStatusCode: res.StatusCode,
   557  		},
   558  	}
   559  	target := &ret
   560  	if err := gensupport.DecodeResponse(target, res); err != nil {
   561  		return nil, err
   562  	}
   563  	return ret, nil
   564  }
   565  
   566  type ProjectsLocationsWorkflowsExecutionsCreateCall struct {
   567  	s          *Service
   568  	parent     string
   569  	execution  *Execution
   570  	urlParams_ gensupport.URLParams
   571  	ctx_       context.Context
   572  	header_    http.Header
   573  }
   574  
   575  // Create: Creates a new execution using the latest revision of the given
   576  // workflow.
   577  //
   578  //   - parent: Name of the workflow for which an execution should be created.
   579  //     Format: projects/{project}/locations/{location}/workflows/{workflow} The
   580  //     latest revision of the workflow will be used.
   581  func (r *ProjectsLocationsWorkflowsExecutionsService) Create(parent string, execution *Execution) *ProjectsLocationsWorkflowsExecutionsCreateCall {
   582  	c := &ProjectsLocationsWorkflowsExecutionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   583  	c.parent = parent
   584  	c.execution = execution
   585  	return c
   586  }
   587  
   588  // Fields allows partial responses to be retrieved. See
   589  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   590  // details.
   591  func (c *ProjectsLocationsWorkflowsExecutionsCreateCall) Fields(s ...googleapi.Field) *ProjectsLocationsWorkflowsExecutionsCreateCall {
   592  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   593  	return c
   594  }
   595  
   596  // Context sets the context to be used in this call's Do method.
   597  func (c *ProjectsLocationsWorkflowsExecutionsCreateCall) Context(ctx context.Context) *ProjectsLocationsWorkflowsExecutionsCreateCall {
   598  	c.ctx_ = ctx
   599  	return c
   600  }
   601  
   602  // Header returns a http.Header that can be modified by the caller to add
   603  // headers to the request.
   604  func (c *ProjectsLocationsWorkflowsExecutionsCreateCall) Header() http.Header {
   605  	if c.header_ == nil {
   606  		c.header_ = make(http.Header)
   607  	}
   608  	return c.header_
   609  }
   610  
   611  func (c *ProjectsLocationsWorkflowsExecutionsCreateCall) doRequest(alt string) (*http.Response, error) {
   612  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   613  	var body io.Reader = nil
   614  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.execution)
   615  	if err != nil {
   616  		return nil, err
   617  	}
   618  	c.urlParams_.Set("alt", alt)
   619  	c.urlParams_.Set("prettyPrint", "false")
   620  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+parent}/executions")
   621  	urls += "?" + c.urlParams_.Encode()
   622  	req, err := http.NewRequest("POST", urls, body)
   623  	if err != nil {
   624  		return nil, err
   625  	}
   626  	req.Header = reqHeaders
   627  	googleapi.Expand(req.URL, map[string]string{
   628  		"parent": c.parent,
   629  	})
   630  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   631  }
   632  
   633  // Do executes the "workflowexecutions.projects.locations.workflows.executions.create" call.
   634  // Any non-2xx status code is an error. Response headers are in either
   635  // *Execution.ServerResponse.Header or (if a response was returned at all) in
   636  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   637  // whether the returned error was because http.StatusNotModified was returned.
   638  func (c *ProjectsLocationsWorkflowsExecutionsCreateCall) Do(opts ...googleapi.CallOption) (*Execution, error) {
   639  	gensupport.SetOptions(c.urlParams_, opts...)
   640  	res, err := c.doRequest("json")
   641  	if res != nil && res.StatusCode == http.StatusNotModified {
   642  		if res.Body != nil {
   643  			res.Body.Close()
   644  		}
   645  		return nil, gensupport.WrapError(&googleapi.Error{
   646  			Code:   res.StatusCode,
   647  			Header: res.Header,
   648  		})
   649  	}
   650  	if err != nil {
   651  		return nil, err
   652  	}
   653  	defer googleapi.CloseBody(res)
   654  	if err := googleapi.CheckResponse(res); err != nil {
   655  		return nil, gensupport.WrapError(err)
   656  	}
   657  	ret := &Execution{
   658  		ServerResponse: googleapi.ServerResponse{
   659  			Header:         res.Header,
   660  			HTTPStatusCode: res.StatusCode,
   661  		},
   662  	}
   663  	target := &ret
   664  	if err := gensupport.DecodeResponse(target, res); err != nil {
   665  		return nil, err
   666  	}
   667  	return ret, nil
   668  }
   669  
   670  type ProjectsLocationsWorkflowsExecutionsGetCall struct {
   671  	s            *Service
   672  	name         string
   673  	urlParams_   gensupport.URLParams
   674  	ifNoneMatch_ string
   675  	ctx_         context.Context
   676  	header_      http.Header
   677  }
   678  
   679  // Get: Returns an execution of the given name.
   680  //
   681  //   - name: Name of the execution to be retrieved. Format:
   682  //     projects/{project}/locations/{location}/workflows/{workflow}/executions/{ex
   683  //     ecution}.
   684  func (r *ProjectsLocationsWorkflowsExecutionsService) Get(name string) *ProjectsLocationsWorkflowsExecutionsGetCall {
   685  	c := &ProjectsLocationsWorkflowsExecutionsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   686  	c.name = name
   687  	return c
   688  }
   689  
   690  // View sets the optional parameter "view": A view defining which fields should
   691  // be filled in the returned execution. The API will default to the FULL view.
   692  //
   693  // Possible values:
   694  //
   695  //	"EXECUTION_VIEW_UNSPECIFIED" - The default / unset value.
   696  //	"BASIC" - Includes only basic metadata about the execution. Following
   697  //
   698  // fields are returned: name, start_time, end_time, state and
   699  // workflow_revision_id.
   700  //
   701  //	"FULL" - Includes all data.
   702  func (c *ProjectsLocationsWorkflowsExecutionsGetCall) View(view string) *ProjectsLocationsWorkflowsExecutionsGetCall {
   703  	c.urlParams_.Set("view", view)
   704  	return c
   705  }
   706  
   707  // Fields allows partial responses to be retrieved. See
   708  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   709  // details.
   710  func (c *ProjectsLocationsWorkflowsExecutionsGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsWorkflowsExecutionsGetCall {
   711  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   712  	return c
   713  }
   714  
   715  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   716  // object's ETag matches the given value. This is useful for getting updates
   717  // only after the object has changed since the last request.
   718  func (c *ProjectsLocationsWorkflowsExecutionsGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsWorkflowsExecutionsGetCall {
   719  	c.ifNoneMatch_ = entityTag
   720  	return c
   721  }
   722  
   723  // Context sets the context to be used in this call's Do method.
   724  func (c *ProjectsLocationsWorkflowsExecutionsGetCall) Context(ctx context.Context) *ProjectsLocationsWorkflowsExecutionsGetCall {
   725  	c.ctx_ = ctx
   726  	return c
   727  }
   728  
   729  // Header returns a http.Header that can be modified by the caller to add
   730  // headers to the request.
   731  func (c *ProjectsLocationsWorkflowsExecutionsGetCall) Header() http.Header {
   732  	if c.header_ == nil {
   733  		c.header_ = make(http.Header)
   734  	}
   735  	return c.header_
   736  }
   737  
   738  func (c *ProjectsLocationsWorkflowsExecutionsGetCall) doRequest(alt string) (*http.Response, error) {
   739  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   740  	if c.ifNoneMatch_ != "" {
   741  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   742  	}
   743  	var body io.Reader = nil
   744  	c.urlParams_.Set("alt", alt)
   745  	c.urlParams_.Set("prettyPrint", "false")
   746  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}")
   747  	urls += "?" + c.urlParams_.Encode()
   748  	req, err := http.NewRequest("GET", urls, body)
   749  	if err != nil {
   750  		return nil, err
   751  	}
   752  	req.Header = reqHeaders
   753  	googleapi.Expand(req.URL, map[string]string{
   754  		"name": c.name,
   755  	})
   756  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   757  }
   758  
   759  // Do executes the "workflowexecutions.projects.locations.workflows.executions.get" call.
   760  // Any non-2xx status code is an error. Response headers are in either
   761  // *Execution.ServerResponse.Header or (if a response was returned at all) in
   762  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   763  // whether the returned error was because http.StatusNotModified was returned.
   764  func (c *ProjectsLocationsWorkflowsExecutionsGetCall) Do(opts ...googleapi.CallOption) (*Execution, error) {
   765  	gensupport.SetOptions(c.urlParams_, opts...)
   766  	res, err := c.doRequest("json")
   767  	if res != nil && res.StatusCode == http.StatusNotModified {
   768  		if res.Body != nil {
   769  			res.Body.Close()
   770  		}
   771  		return nil, gensupport.WrapError(&googleapi.Error{
   772  			Code:   res.StatusCode,
   773  			Header: res.Header,
   774  		})
   775  	}
   776  	if err != nil {
   777  		return nil, err
   778  	}
   779  	defer googleapi.CloseBody(res)
   780  	if err := googleapi.CheckResponse(res); err != nil {
   781  		return nil, gensupport.WrapError(err)
   782  	}
   783  	ret := &Execution{
   784  		ServerResponse: googleapi.ServerResponse{
   785  			Header:         res.Header,
   786  			HTTPStatusCode: res.StatusCode,
   787  		},
   788  	}
   789  	target := &ret
   790  	if err := gensupport.DecodeResponse(target, res); err != nil {
   791  		return nil, err
   792  	}
   793  	return ret, nil
   794  }
   795  
   796  type ProjectsLocationsWorkflowsExecutionsListCall struct {
   797  	s            *Service
   798  	parent       string
   799  	urlParams_   gensupport.URLParams
   800  	ifNoneMatch_ string
   801  	ctx_         context.Context
   802  	header_      http.Header
   803  }
   804  
   805  // List: Returns a list of executions which belong to the workflow with the
   806  // given name. The method returns executions of all workflow revisions.
   807  // Returned executions are ordered by their start time (newest first).
   808  //
   809  //   - parent: Name of the workflow for which the executions should be listed.
   810  //     Format: projects/{project}/locations/{location}/workflows/{workflow}.
   811  func (r *ProjectsLocationsWorkflowsExecutionsService) List(parent string) *ProjectsLocationsWorkflowsExecutionsListCall {
   812  	c := &ProjectsLocationsWorkflowsExecutionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   813  	c.parent = parent
   814  	return c
   815  }
   816  
   817  // PageSize sets the optional parameter "pageSize": Maximum number of
   818  // executions to return per call. Max supported value depends on the selected
   819  // Execution view: it's 10000 for BASIC and 100 for FULL. The default value
   820  // used if the field is not specified is 100, regardless of the selected view.
   821  // Values greater than the max value will be coerced down to it.
   822  func (c *ProjectsLocationsWorkflowsExecutionsListCall) PageSize(pageSize int64) *ProjectsLocationsWorkflowsExecutionsListCall {
   823  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   824  	return c
   825  }
   826  
   827  // PageToken sets the optional parameter "pageToken": A page token, received
   828  // from a previous `ListExecutions` call. Provide this to retrieve the
   829  // subsequent page. When paginating, all other parameters provided to
   830  // `ListExecutions` must match the call that provided the page token.
   831  func (c *ProjectsLocationsWorkflowsExecutionsListCall) PageToken(pageToken string) *ProjectsLocationsWorkflowsExecutionsListCall {
   832  	c.urlParams_.Set("pageToken", pageToken)
   833  	return c
   834  }
   835  
   836  // View sets the optional parameter "view": A view defining which fields should
   837  // be filled in the returned executions. The API will default to the BASIC
   838  // view.
   839  //
   840  // Possible values:
   841  //
   842  //	"EXECUTION_VIEW_UNSPECIFIED" - The default / unset value.
   843  //	"BASIC" - Includes only basic metadata about the execution. Following
   844  //
   845  // fields are returned: name, start_time, end_time, state and
   846  // workflow_revision_id.
   847  //
   848  //	"FULL" - Includes all data.
   849  func (c *ProjectsLocationsWorkflowsExecutionsListCall) View(view string) *ProjectsLocationsWorkflowsExecutionsListCall {
   850  	c.urlParams_.Set("view", view)
   851  	return c
   852  }
   853  
   854  // Fields allows partial responses to be retrieved. See
   855  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   856  // details.
   857  func (c *ProjectsLocationsWorkflowsExecutionsListCall) Fields(s ...googleapi.Field) *ProjectsLocationsWorkflowsExecutionsListCall {
   858  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   859  	return c
   860  }
   861  
   862  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   863  // object's ETag matches the given value. This is useful for getting updates
   864  // only after the object has changed since the last request.
   865  func (c *ProjectsLocationsWorkflowsExecutionsListCall) IfNoneMatch(entityTag string) *ProjectsLocationsWorkflowsExecutionsListCall {
   866  	c.ifNoneMatch_ = entityTag
   867  	return c
   868  }
   869  
   870  // Context sets the context to be used in this call's Do method.
   871  func (c *ProjectsLocationsWorkflowsExecutionsListCall) Context(ctx context.Context) *ProjectsLocationsWorkflowsExecutionsListCall {
   872  	c.ctx_ = ctx
   873  	return c
   874  }
   875  
   876  // Header returns a http.Header that can be modified by the caller to add
   877  // headers to the request.
   878  func (c *ProjectsLocationsWorkflowsExecutionsListCall) Header() http.Header {
   879  	if c.header_ == nil {
   880  		c.header_ = make(http.Header)
   881  	}
   882  	return c.header_
   883  }
   884  
   885  func (c *ProjectsLocationsWorkflowsExecutionsListCall) doRequest(alt string) (*http.Response, error) {
   886  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   887  	if c.ifNoneMatch_ != "" {
   888  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   889  	}
   890  	var body io.Reader = nil
   891  	c.urlParams_.Set("alt", alt)
   892  	c.urlParams_.Set("prettyPrint", "false")
   893  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+parent}/executions")
   894  	urls += "?" + c.urlParams_.Encode()
   895  	req, err := http.NewRequest("GET", urls, body)
   896  	if err != nil {
   897  		return nil, err
   898  	}
   899  	req.Header = reqHeaders
   900  	googleapi.Expand(req.URL, map[string]string{
   901  		"parent": c.parent,
   902  	})
   903  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   904  }
   905  
   906  // Do executes the "workflowexecutions.projects.locations.workflows.executions.list" call.
   907  // Any non-2xx status code is an error. Response headers are in either
   908  // *ListExecutionsResponse.ServerResponse.Header or (if a response was returned
   909  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   910  // check whether the returned error was because http.StatusNotModified was
   911  // returned.
   912  func (c *ProjectsLocationsWorkflowsExecutionsListCall) Do(opts ...googleapi.CallOption) (*ListExecutionsResponse, error) {
   913  	gensupport.SetOptions(c.urlParams_, opts...)
   914  	res, err := c.doRequest("json")
   915  	if res != nil && res.StatusCode == http.StatusNotModified {
   916  		if res.Body != nil {
   917  			res.Body.Close()
   918  		}
   919  		return nil, gensupport.WrapError(&googleapi.Error{
   920  			Code:   res.StatusCode,
   921  			Header: res.Header,
   922  		})
   923  	}
   924  	if err != nil {
   925  		return nil, err
   926  	}
   927  	defer googleapi.CloseBody(res)
   928  	if err := googleapi.CheckResponse(res); err != nil {
   929  		return nil, gensupport.WrapError(err)
   930  	}
   931  	ret := &ListExecutionsResponse{
   932  		ServerResponse: googleapi.ServerResponse{
   933  			Header:         res.Header,
   934  			HTTPStatusCode: res.StatusCode,
   935  		},
   936  	}
   937  	target := &ret
   938  	if err := gensupport.DecodeResponse(target, res); err != nil {
   939  		return nil, err
   940  	}
   941  	return ret, nil
   942  }
   943  
   944  // Pages invokes f for each page of results.
   945  // A non-nil error returned from f will halt the iteration.
   946  // The provided context supersedes any context provided to the Context method.
   947  func (c *ProjectsLocationsWorkflowsExecutionsListCall) Pages(ctx context.Context, f func(*ListExecutionsResponse) error) error {
   948  	c.ctx_ = ctx
   949  	defer c.PageToken(c.urlParams_.Get("pageToken"))
   950  	for {
   951  		x, err := c.Do()
   952  		if err != nil {
   953  			return err
   954  		}
   955  		if err := f(x); err != nil {
   956  			return err
   957  		}
   958  		if x.NextPageToken == "" {
   959  			return nil
   960  		}
   961  		c.PageToken(x.NextPageToken)
   962  	}
   963  }
   964  

View as plain text