github.com/qiniu/go-sdk/v7@v7.27.0/sandbox/internal/envdapi/envd.gen.go (about)

     1  // Package envdapi provides primitives to interact with the openapi HTTP API.
     2  //
     3  // Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.
     4  package envdapi
     5  
     6  import (
     7  	"bytes"
     8  	"context"
     9  	"encoding/json"
    10  	"fmt"
    11  	"io"
    12  	"net/http"
    13  	"net/url"
    14  	"strings"
    15  	"time"
    16  
    17  	"github.com/oapi-codegen/runtime"
    18  	openapi_types "github.com/oapi-codegen/runtime/types"
    19  )
    20  
    21  const (
    22  	AccessTokenAuthScopes = "AccessTokenAuth.Scopes"
    23  )
    24  
    25  // Defines values for EntryInfoType.
    26  const (
    27  	File EntryInfoType = "file"
    28  )
    29  
    30  // EntryInfo defines model for EntryInfo.
    31  type EntryInfo struct {
    32  	// Name Name of the file
    33  	Name string `json:"name"`
    34  
    35  	// Path Path to the file
    36  	Path string `json:"path"`
    37  
    38  	// Type Type of the file
    39  	Type EntryInfoType `json:"type"`
    40  }
    41  
    42  // EntryInfoType Type of the file
    43  type EntryInfoType string
    44  
    45  // EnvVars Environment variables to set
    46  type EnvVars map[string]string
    47  
    48  // Error defines model for Error.
    49  type Error struct {
    50  	// Code Error code
    51  	Code int `json:"code"`
    52  
    53  	// Message Error message
    54  	Message string `json:"message"`
    55  }
    56  
    57  // Metrics Resource usage metrics
    58  type Metrics struct {
    59  	// CPUCount Number of CPU cores
    60  	CPUCount *int `json:"cpu_count,omitempty"`
    61  
    62  	// CPUUsedPct CPU usage percentage
    63  	CPUUsedPct *float32 `json:"cpu_used_pct,omitempty"`
    64  
    65  	// DiskTotal Total disk space in bytes
    66  	DiskTotal *int `json:"disk_total,omitempty"`
    67  
    68  	// DiskUsed Used disk space in bytes
    69  	DiskUsed *int `json:"disk_used,omitempty"`
    70  
    71  	// MemTotal Total virtual memory in bytes
    72  	MemTotal *int `json:"mem_total,omitempty"`
    73  
    74  	// MemUsed Used virtual memory in bytes
    75  	MemUsed *int `json:"mem_used,omitempty"`
    76  
    77  	// TS Unix timestamp in UTC for current sandbox time
    78  	TS *int64 `json:"ts,omitempty"`
    79  }
    80  
    81  // Mount defines model for Mount.
    82  type Mount struct {
    83  	// Options Extra arguments passed verbatim to mount(8) before the source and target (e.g. `["-t", "ext4", "-o", "ro,nosuid"]`, or `["--bind"]` for bind mounts).
    84  	Options *[]string `json:"options,omitempty"`
    85  
    86  	// SourcePath Mount source (block device, NFS target, or another path)
    87  	SourcePath string `json:"sourcePath"`
    88  
    89  	// TargetPath Absolute path inside the sandbox where the source is mounted
    90  	TargetPath string `json:"targetPath"`
    91  }
    92  
    93  // PostInitAction defines model for PostInitAction.
    94  type PostInitAction struct {
    95  	// Argv Command argv to execute directly without a shell
    96  	Argv []string `json:"argv"`
    97  
    98  	// Cwd Optional working directory for the command
    99  	Cwd *string `json:"cwd,omitempty"`
   100  
   101  	// EnvVars Environment variables to set
   102  	EnvVars *EnvVars `json:"envVars,omitempty"`
   103  
   104  	// TimeoutMs Optional timeout in milliseconds for this command
   105  	TimeoutMs *int64 `json:"timeoutMs,omitempty"`
   106  
   107  	// User Optional target user to run the command as
   108  	User *string `json:"user,omitempty"`
   109  }
   110  
   111  // FilePath defines model for FilePath.
   112  type FilePath = string
   113  
   114  // Signature defines model for Signature.
   115  type Signature = string
   116  
   117  // SignatureExpiration defines model for SignatureExpiration.
   118  type SignatureExpiration = int
   119  
   120  // User defines model for User.
   121  type User = string
   122  
   123  // FileNotFound defines model for FileNotFound.
   124  type FileNotFound = Error
   125  
   126  // InternalServerError defines model for InternalServerError.
   127  type InternalServerError = Error
   128  
   129  // InvalidPath defines model for InvalidPath.
   130  type InvalidPath = Error
   131  
   132  // InvalidUser defines model for InvalidUser.
   133  type InvalidUser = Error
   134  
   135  // NotEnoughDiskSpace defines model for NotEnoughDiskSpace.
   136  type NotEnoughDiskSpace = Error
   137  
   138  // UploadSuccess defines model for UploadSuccess.
   139  type UploadSuccess = []EntryInfo
   140  
   141  // GetFilesParams defines parameters for GetFiles.
   142  type GetFilesParams struct {
   143  	// Path Path to the file, URL encoded. Can be relative to user's home directory.
   144  	Path *FilePath `form:"path,omitempty" json:"path,omitempty"`
   145  
   146  	// Username User used for setting the owner, or resolving relative paths.
   147  	Username *User `form:"username,omitempty" json:"username,omitempty"`
   148  
   149  	// Signature Signature used for file access permission verification.
   150  	Signature *Signature `form:"signature,omitempty" json:"signature,omitempty"`
   151  
   152  	// SignatureExpiration Signature expiration used for defining the expiration time of the signature.
   153  	SignatureExpiration *SignatureExpiration `form:"signature_expiration,omitempty" json:"signature_expiration,omitempty"`
   154  }
   155  
   156  // PostFilesMultipartBody defines parameters for PostFiles.
   157  type PostFilesMultipartBody struct {
   158  	File *openapi_types.File `json:"file,omitempty"`
   159  }
   160  
   161  // PostFilesParams defines parameters for PostFiles.
   162  type PostFilesParams struct {
   163  	// Path Path to the file, URL encoded. Can be relative to user's home directory.
   164  	Path *FilePath `form:"path,omitempty" json:"path,omitempty"`
   165  
   166  	// Username User used for setting the owner, or resolving relative paths.
   167  	Username *User `form:"username,omitempty" json:"username,omitempty"`
   168  
   169  	// Signature Signature used for file access permission verification.
   170  	Signature *Signature `form:"signature,omitempty" json:"signature,omitempty"`
   171  
   172  	// SignatureExpiration Signature expiration used for defining the expiration time of the signature.
   173  	SignatureExpiration *SignatureExpiration `form:"signature_expiration,omitempty" json:"signature_expiration,omitempty"`
   174  }
   175  
   176  // PostInitJSONBody defines parameters for PostInit.
   177  type PostInitJSONBody struct {
   178  	// AccessToken Access token for secure access to envd service
   179  	AccessToken *string `json:"accessToken,omitempty"`
   180  
   181  	// CaCertPEM CA certificate in PEM format for MITM APIKEY protection to be injected into the sandbox system trust store
   182  	CaCertPEM *string `json:"caCertPEM,omitempty"`
   183  
   184  	// DefaultUser The default user to use for operations
   185  	DefaultUser *string `json:"defaultUser,omitempty"`
   186  
   187  	// DefaultWorkdir The default working directory to use for operations
   188  	DefaultWorkdir *string `json:"defaultWorkdir,omitempty"`
   189  
   190  	// EnvVars Environment variables to set
   191  	EnvVars *EnvVars `json:"envVars,omitempty"`
   192  
   193  	// HyperloopIP IP address of the hyperloop server to connect to
   194  	HyperloopIP *string `json:"hyperloopIP,omitempty"`
   195  
   196  	// Mounts Mounts to set up inside the sandbox before post-init actions run
   197  	Mounts          *[]Mount          `json:"mounts,omitempty"`
   198  	PostInitActions *[]PostInitAction `json:"postInitActions,omitempty"`
   199  
   200  	// Timestamp The current timestamp in RFC3339 format
   201  	Timestamp *time.Time `json:"timestamp,omitempty"`
   202  }
   203  
   204  // PostFilesMultipartRequestBody defines body for PostFiles for multipart/form-data ContentType.
   205  type PostFilesMultipartRequestBody PostFilesMultipartBody
   206  
   207  // PostInitJSONRequestBody defines body for PostInit for application/json ContentType.
   208  type PostInitJSONRequestBody PostInitJSONBody
   209  
   210  // RequestEditorFn  is the function signature for the RequestEditor callback function
   211  type RequestEditorFn func(ctx context.Context, req *http.Request) error
   212  
   213  // Doer performs HTTP requests.
   214  //
   215  // The standard http.Client implements this interface.
   216  type HttpRequestDoer interface {
   217  	Do(req *http.Request) (*http.Response, error)
   218  }
   219  
   220  // Client which conforms to the OpenAPI3 specification for this service.
   221  type Client struct {
   222  	// The endpoint of the server conforming to this interface, with scheme,
   223  	// https://api.deepmap.com for example. This can contain a path relative
   224  	// to the server, such as https://api.deepmap.com/dev-test, and all the
   225  	// paths in the swagger spec will be appended to the server.
   226  	Server string
   227  
   228  	// Doer for performing requests, typically a *http.Client with any
   229  	// customized settings, such as certificate chains.
   230  	Client HttpRequestDoer
   231  
   232  	// A list of callbacks for modifying requests which are generated before sending over
   233  	// the network.
   234  	RequestEditors []RequestEditorFn
   235  }
   236  
   237  // ClientOption allows setting custom parameters during construction
   238  type ClientOption func(*Client) error
   239  
   240  // Creates a new Client, with reasonable defaults
   241  func NewClient(server string, opts ...ClientOption) (*Client, error) {
   242  	// create a client with sane default values
   243  	client := Client{
   244  		Server: server,
   245  	}
   246  	// mutate client and add all optional params
   247  	for _, o := range opts {
   248  		if err := o(&client); err != nil {
   249  			return nil, err
   250  		}
   251  	}
   252  	// ensure the server URL always has a trailing slash
   253  	if !strings.HasSuffix(client.Server, "/") {
   254  		client.Server += "/"
   255  	}
   256  	// create httpClient, if not already present
   257  	if client.Client == nil {
   258  		client.Client = &http.Client{}
   259  	}
   260  	return &client, nil
   261  }
   262  
   263  // WithHTTPClient allows overriding the default Doer, which is
   264  // automatically created using http.Client. This is useful for tests.
   265  func WithHTTPClient(doer HttpRequestDoer) ClientOption {
   266  	return func(c *Client) error {
   267  		c.Client = doer
   268  		return nil
   269  	}
   270  }
   271  
   272  // WithRequestEditorFn allows setting up a callback function, which will be
   273  // called right before sending the request. This can be used to mutate the request.
   274  func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
   275  	return func(c *Client) error {
   276  		c.RequestEditors = append(c.RequestEditors, fn)
   277  		return nil
   278  	}
   279  }
   280  
   281  // The interface specification for the client above.
   282  type ClientInterface interface {
   283  	// GetEnvs request
   284  	GetEnvs(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
   285  
   286  	// GetFiles request
   287  	GetFiles(ctx context.Context, params *GetFilesParams, reqEditors ...RequestEditorFn) (*http.Response, error)
   288  
   289  	// PostFilesWithBody request with any body
   290  	PostFilesWithBody(ctx context.Context, params *PostFilesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
   291  
   292  	// GetHealth request
   293  	GetHealth(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
   294  
   295  	// PostInitWithBody request with any body
   296  	PostInitWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
   297  
   298  	PostInit(ctx context.Context, body PostInitJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
   299  
   300  	// GetMetrics request
   301  	GetMetrics(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
   302  }
   303  
   304  func (c *Client) GetEnvs(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
   305  	req, err := NewGetEnvsRequest(c.Server)
   306  	if err != nil {
   307  		return nil, err
   308  	}
   309  	req = req.WithContext(ctx)
   310  	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
   311  		return nil, err
   312  	}
   313  	return c.Client.Do(req)
   314  }
   315  
   316  func (c *Client) GetFiles(ctx context.Context, params *GetFilesParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
   317  	req, err := NewGetFilesRequest(c.Server, params)
   318  	if err != nil {
   319  		return nil, err
   320  	}
   321  	req = req.WithContext(ctx)
   322  	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
   323  		return nil, err
   324  	}
   325  	return c.Client.Do(req)
   326  }
   327  
   328  func (c *Client) PostFilesWithBody(ctx context.Context, params *PostFilesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
   329  	req, err := NewPostFilesRequestWithBody(c.Server, params, contentType, body)
   330  	if err != nil {
   331  		return nil, err
   332  	}
   333  	req = req.WithContext(ctx)
   334  	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
   335  		return nil, err
   336  	}
   337  	return c.Client.Do(req)
   338  }
   339  
   340  func (c *Client) GetHealth(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
   341  	req, err := NewGetHealthRequest(c.Server)
   342  	if err != nil {
   343  		return nil, err
   344  	}
   345  	req = req.WithContext(ctx)
   346  	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
   347  		return nil, err
   348  	}
   349  	return c.Client.Do(req)
   350  }
   351  
   352  func (c *Client) PostInitWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
   353  	req, err := NewPostInitRequestWithBody(c.Server, contentType, body)
   354  	if err != nil {
   355  		return nil, err
   356  	}
   357  	req = req.WithContext(ctx)
   358  	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
   359  		return nil, err
   360  	}
   361  	return c.Client.Do(req)
   362  }
   363  
   364  func (c *Client) PostInit(ctx context.Context, body PostInitJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
   365  	req, err := NewPostInitRequest(c.Server, body)
   366  	if err != nil {
   367  		return nil, err
   368  	}
   369  	req = req.WithContext(ctx)
   370  	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
   371  		return nil, err
   372  	}
   373  	return c.Client.Do(req)
   374  }
   375  
   376  func (c *Client) GetMetrics(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
   377  	req, err := NewGetMetricsRequest(c.Server)
   378  	if err != nil {
   379  		return nil, err
   380  	}
   381  	req = req.WithContext(ctx)
   382  	if err := c.applyEditors(ctx, req, reqEditors); err != nil {
   383  		return nil, err
   384  	}
   385  	return c.Client.Do(req)
   386  }
   387  
   388  // NewGetEnvsRequest generates requests for GetEnvs
   389  func NewGetEnvsRequest(server string) (*http.Request, error) {
   390  	var err error
   391  
   392  	serverURL, err := url.Parse(server)
   393  	if err != nil {
   394  		return nil, err
   395  	}
   396  
   397  	operationPath := fmt.Sprintf("/envs")
   398  	if operationPath[0] == '/' {
   399  		operationPath = "." + operationPath
   400  	}
   401  
   402  	queryURL, err := serverURL.Parse(operationPath)
   403  	if err != nil {
   404  		return nil, err
   405  	}
   406  
   407  	req, err := http.NewRequest("GET", queryURL.String(), nil)
   408  	if err != nil {
   409  		return nil, err
   410  	}
   411  
   412  	return req, nil
   413  }
   414  
   415  // NewGetFilesRequest generates requests for GetFiles
   416  func NewGetFilesRequest(server string, params *GetFilesParams) (*http.Request, error) {
   417  	var err error
   418  
   419  	serverURL, err := url.Parse(server)
   420  	if err != nil {
   421  		return nil, err
   422  	}
   423  
   424  	operationPath := fmt.Sprintf("/files")
   425  	if operationPath[0] == '/' {
   426  		operationPath = "." + operationPath
   427  	}
   428  
   429  	queryURL, err := serverURL.Parse(operationPath)
   430  	if err != nil {
   431  		return nil, err
   432  	}
   433  
   434  	if params != nil {
   435  		queryValues := queryURL.Query()
   436  
   437  		if params.Path != nil {
   438  
   439  			if queryFrag, err := runtime.StyleParamWithLocation("form", true, "path", runtime.ParamLocationQuery, *params.Path); err != nil {
   440  				return nil, err
   441  			} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
   442  				return nil, err
   443  			} else {
   444  				for k, v := range parsed {
   445  					for _, v2 := range v {
   446  						queryValues.Add(k, v2)
   447  					}
   448  				}
   449  			}
   450  
   451  		}
   452  
   453  		if params.Username != nil {
   454  
   455  			if queryFrag, err := runtime.StyleParamWithLocation("form", true, "username", runtime.ParamLocationQuery, *params.Username); err != nil {
   456  				return nil, err
   457  			} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
   458  				return nil, err
   459  			} else {
   460  				for k, v := range parsed {
   461  					for _, v2 := range v {
   462  						queryValues.Add(k, v2)
   463  					}
   464  				}
   465  			}
   466  
   467  		}
   468  
   469  		if params.Signature != nil {
   470  
   471  			if queryFrag, err := runtime.StyleParamWithLocation("form", true, "signature", runtime.ParamLocationQuery, *params.Signature); err != nil {
   472  				return nil, err
   473  			} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
   474  				return nil, err
   475  			} else {
   476  				for k, v := range parsed {
   477  					for _, v2 := range v {
   478  						queryValues.Add(k, v2)
   479  					}
   480  				}
   481  			}
   482  
   483  		}
   484  
   485  		if params.SignatureExpiration != nil {
   486  
   487  			if queryFrag, err := runtime.StyleParamWithLocation("form", true, "signature_expiration", runtime.ParamLocationQuery, *params.SignatureExpiration); err != nil {
   488  				return nil, err
   489  			} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
   490  				return nil, err
   491  			} else {
   492  				for k, v := range parsed {
   493  					for _, v2 := range v {
   494  						queryValues.Add(k, v2)
   495  					}
   496  				}
   497  			}
   498  
   499  		}
   500  
   501  		queryURL.RawQuery = queryValues.Encode()
   502  	}
   503  
   504  	req, err := http.NewRequest("GET", queryURL.String(), nil)
   505  	if err != nil {
   506  		return nil, err
   507  	}
   508  
   509  	return req, nil
   510  }
   511  
   512  // NewPostFilesRequestWithBody generates requests for PostFiles with any type of body
   513  func NewPostFilesRequestWithBody(server string, params *PostFilesParams, contentType string, body io.Reader) (*http.Request, error) {
   514  	var err error
   515  
   516  	serverURL, err := url.Parse(server)
   517  	if err != nil {
   518  		return nil, err
   519  	}
   520  
   521  	operationPath := fmt.Sprintf("/files")
   522  	if operationPath[0] == '/' {
   523  		operationPath = "." + operationPath
   524  	}
   525  
   526  	queryURL, err := serverURL.Parse(operationPath)
   527  	if err != nil {
   528  		return nil, err
   529  	}
   530  
   531  	if params != nil {
   532  		queryValues := queryURL.Query()
   533  
   534  		if params.Path != nil {
   535  
   536  			if queryFrag, err := runtime.StyleParamWithLocation("form", true, "path", runtime.ParamLocationQuery, *params.Path); err != nil {
   537  				return nil, err
   538  			} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
   539  				return nil, err
   540  			} else {
   541  				for k, v := range parsed {
   542  					for _, v2 := range v {
   543  						queryValues.Add(k, v2)
   544  					}
   545  				}
   546  			}
   547  
   548  		}
   549  
   550  		if params.Username != nil {
   551  
   552  			if queryFrag, err := runtime.StyleParamWithLocation("form", true, "username", runtime.ParamLocationQuery, *params.Username); err != nil {
   553  				return nil, err
   554  			} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
   555  				return nil, err
   556  			} else {
   557  				for k, v := range parsed {
   558  					for _, v2 := range v {
   559  						queryValues.Add(k, v2)
   560  					}
   561  				}
   562  			}
   563  
   564  		}
   565  
   566  		if params.Signature != nil {
   567  
   568  			if queryFrag, err := runtime.StyleParamWithLocation("form", true, "signature", runtime.ParamLocationQuery, *params.Signature); err != nil {
   569  				return nil, err
   570  			} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
   571  				return nil, err
   572  			} else {
   573  				for k, v := range parsed {
   574  					for _, v2 := range v {
   575  						queryValues.Add(k, v2)
   576  					}
   577  				}
   578  			}
   579  
   580  		}
   581  
   582  		if params.SignatureExpiration != nil {
   583  
   584  			if queryFrag, err := runtime.StyleParamWithLocation("form", true, "signature_expiration", runtime.ParamLocationQuery, *params.SignatureExpiration); err != nil {
   585  				return nil, err
   586  			} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
   587  				return nil, err
   588  			} else {
   589  				for k, v := range parsed {
   590  					for _, v2 := range v {
   591  						queryValues.Add(k, v2)
   592  					}
   593  				}
   594  			}
   595  
   596  		}
   597  
   598  		queryURL.RawQuery = queryValues.Encode()
   599  	}
   600  
   601  	req, err := http.NewRequest("POST", queryURL.String(), body)
   602  	if err != nil {
   603  		return nil, err
   604  	}
   605  
   606  	req.Header.Add("Content-Type", contentType)
   607  
   608  	return req, nil
   609  }
   610  
   611  // NewGetHealthRequest generates requests for GetHealth
   612  func NewGetHealthRequest(server string) (*http.Request, error) {
   613  	var err error
   614  
   615  	serverURL, err := url.Parse(server)
   616  	if err != nil {
   617  		return nil, err
   618  	}
   619  
   620  	operationPath := fmt.Sprintf("/health")
   621  	if operationPath[0] == '/' {
   622  		operationPath = "." + operationPath
   623  	}
   624  
   625  	queryURL, err := serverURL.Parse(operationPath)
   626  	if err != nil {
   627  		return nil, err
   628  	}
   629  
   630  	req, err := http.NewRequest("GET", queryURL.String(), nil)
   631  	if err != nil {
   632  		return nil, err
   633  	}
   634  
   635  	return req, nil
   636  }
   637  
   638  // NewPostInitRequest calls the generic PostInit builder with application/json body
   639  func NewPostInitRequest(server string, body PostInitJSONRequestBody) (*http.Request, error) {
   640  	var bodyReader io.Reader
   641  	buf, err := json.Marshal(body)
   642  	if err != nil {
   643  		return nil, err
   644  	}
   645  	bodyReader = bytes.NewReader(buf)
   646  	return NewPostInitRequestWithBody(server, "application/json", bodyReader)
   647  }
   648  
   649  // NewPostInitRequestWithBody generates requests for PostInit with any type of body
   650  func NewPostInitRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
   651  	var err error
   652  
   653  	serverURL, err := url.Parse(server)
   654  	if err != nil {
   655  		return nil, err
   656  	}
   657  
   658  	operationPath := fmt.Sprintf("/init")
   659  	if operationPath[0] == '/' {
   660  		operationPath = "." + operationPath
   661  	}
   662  
   663  	queryURL, err := serverURL.Parse(operationPath)
   664  	if err != nil {
   665  		return nil, err
   666  	}
   667  
   668  	req, err := http.NewRequest("POST", queryURL.String(), body)
   669  	if err != nil {
   670  		return nil, err
   671  	}
   672  
   673  	req.Header.Add("Content-Type", contentType)
   674  
   675  	return req, nil
   676  }
   677  
   678  // NewGetMetricsRequest generates requests for GetMetrics
   679  func NewGetMetricsRequest(server string) (*http.Request, error) {
   680  	var err error
   681  
   682  	serverURL, err := url.Parse(server)
   683  	if err != nil {
   684  		return nil, err
   685  	}
   686  
   687  	operationPath := fmt.Sprintf("/metrics")
   688  	if operationPath[0] == '/' {
   689  		operationPath = "." + operationPath
   690  	}
   691  
   692  	queryURL, err := serverURL.Parse(operationPath)
   693  	if err != nil {
   694  		return nil, err
   695  	}
   696  
   697  	req, err := http.NewRequest("GET", queryURL.String(), nil)
   698  	if err != nil {
   699  		return nil, err
   700  	}
   701  
   702  	return req, nil
   703  }
   704  
   705  func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error {
   706  	for _, r := range c.RequestEditors {
   707  		if err := r(ctx, req); err != nil {
   708  			return err
   709  		}
   710  	}
   711  	for _, r := range additionalEditors {
   712  		if err := r(ctx, req); err != nil {
   713  			return err
   714  		}
   715  	}
   716  	return nil
   717  }
   718  
   719  // ClientWithResponses builds on ClientInterface to offer response payloads
   720  type ClientWithResponses struct {
   721  	ClientInterface
   722  }
   723  
   724  // NewClientWithResponses creates a new ClientWithResponses, which wraps
   725  // Client with return type handling
   726  func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
   727  	client, err := NewClient(server, opts...)
   728  	if err != nil {
   729  		return nil, err
   730  	}
   731  	return &ClientWithResponses{client}, nil
   732  }
   733  
   734  // WithBaseURL overrides the baseURL.
   735  func WithBaseURL(baseURL string) ClientOption {
   736  	return func(c *Client) error {
   737  		newBaseURL, err := url.Parse(baseURL)
   738  		if err != nil {
   739  			return err
   740  		}
   741  		c.Server = newBaseURL.String()
   742  		return nil
   743  	}
   744  }
   745  
   746  // ClientWithResponsesInterface is the interface specification for the client with responses above.
   747  type ClientWithResponsesInterface interface {
   748  	// GetEnvsWithResponse request
   749  	GetEnvsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetEnvsResponse, error)
   750  
   751  	// GetFilesWithResponse request
   752  	GetFilesWithResponse(ctx context.Context, params *GetFilesParams, reqEditors ...RequestEditorFn) (*GetFilesResponse, error)
   753  
   754  	// PostFilesWithBodyWithResponse request with any body
   755  	PostFilesWithBodyWithResponse(ctx context.Context, params *PostFilesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFilesResponse, error)
   756  
   757  	// GetHealthWithResponse request
   758  	GetHealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHealthResponse, error)
   759  
   760  	// PostInitWithBodyWithResponse request with any body
   761  	PostInitWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostInitResponse, error)
   762  
   763  	PostInitWithResponse(ctx context.Context, body PostInitJSONRequestBody, reqEditors ...RequestEditorFn) (*PostInitResponse, error)
   764  
   765  	// GetMetricsWithResponse request
   766  	GetMetricsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetMetricsResponse, error)
   767  }
   768  
   769  type GetEnvsResponse struct {
   770  	Body         []byte
   771  	HTTPResponse *http.Response
   772  	JSON200      *EnvVars
   773  }
   774  
   775  // Status returns HTTPResponse.Status
   776  func (r GetEnvsResponse) Status() string {
   777  	if r.HTTPResponse != nil {
   778  		return r.HTTPResponse.Status
   779  	}
   780  	return http.StatusText(0)
   781  }
   782  
   783  // StatusCode returns HTTPResponse.StatusCode
   784  func (r GetEnvsResponse) StatusCode() int {
   785  	if r.HTTPResponse != nil {
   786  		return r.HTTPResponse.StatusCode
   787  	}
   788  	return 0
   789  }
   790  
   791  type GetFilesResponse struct {
   792  	Body         []byte
   793  	HTTPResponse *http.Response
   794  	JSON400      *InvalidPath
   795  	JSON401      *InvalidUser
   796  	JSON404      *FileNotFound
   797  	JSON500      *InternalServerError
   798  }
   799  
   800  // Status returns HTTPResponse.Status
   801  func (r GetFilesResponse) Status() string {
   802  	if r.HTTPResponse != nil {
   803  		return r.HTTPResponse.Status
   804  	}
   805  	return http.StatusText(0)
   806  }
   807  
   808  // StatusCode returns HTTPResponse.StatusCode
   809  func (r GetFilesResponse) StatusCode() int {
   810  	if r.HTTPResponse != nil {
   811  		return r.HTTPResponse.StatusCode
   812  	}
   813  	return 0
   814  }
   815  
   816  type PostFilesResponse struct {
   817  	Body         []byte
   818  	HTTPResponse *http.Response
   819  	JSON200      *UploadSuccess
   820  	JSON400      *InvalidPath
   821  	JSON401      *InvalidUser
   822  	JSON500      *InternalServerError
   823  	JSON507      *NotEnoughDiskSpace
   824  }
   825  
   826  // Status returns HTTPResponse.Status
   827  func (r PostFilesResponse) Status() string {
   828  	if r.HTTPResponse != nil {
   829  		return r.HTTPResponse.Status
   830  	}
   831  	return http.StatusText(0)
   832  }
   833  
   834  // StatusCode returns HTTPResponse.StatusCode
   835  func (r PostFilesResponse) StatusCode() int {
   836  	if r.HTTPResponse != nil {
   837  		return r.HTTPResponse.StatusCode
   838  	}
   839  	return 0
   840  }
   841  
   842  type GetHealthResponse struct {
   843  	Body         []byte
   844  	HTTPResponse *http.Response
   845  }
   846  
   847  // Status returns HTTPResponse.Status
   848  func (r GetHealthResponse) Status() string {
   849  	if r.HTTPResponse != nil {
   850  		return r.HTTPResponse.Status
   851  	}
   852  	return http.StatusText(0)
   853  }
   854  
   855  // StatusCode returns HTTPResponse.StatusCode
   856  func (r GetHealthResponse) StatusCode() int {
   857  	if r.HTTPResponse != nil {
   858  		return r.HTTPResponse.StatusCode
   859  	}
   860  	return 0
   861  }
   862  
   863  type PostInitResponse struct {
   864  	Body         []byte
   865  	HTTPResponse *http.Response
   866  }
   867  
   868  // Status returns HTTPResponse.Status
   869  func (r PostInitResponse) Status() string {
   870  	if r.HTTPResponse != nil {
   871  		return r.HTTPResponse.Status
   872  	}
   873  	return http.StatusText(0)
   874  }
   875  
   876  // StatusCode returns HTTPResponse.StatusCode
   877  func (r PostInitResponse) StatusCode() int {
   878  	if r.HTTPResponse != nil {
   879  		return r.HTTPResponse.StatusCode
   880  	}
   881  	return 0
   882  }
   883  
   884  type GetMetricsResponse struct {
   885  	Body         []byte
   886  	HTTPResponse *http.Response
   887  	JSON200      *Metrics
   888  }
   889  
   890  // Status returns HTTPResponse.Status
   891  func (r GetMetricsResponse) Status() string {
   892  	if r.HTTPResponse != nil {
   893  		return r.HTTPResponse.Status
   894  	}
   895  	return http.StatusText(0)
   896  }
   897  
   898  // StatusCode returns HTTPResponse.StatusCode
   899  func (r GetMetricsResponse) StatusCode() int {
   900  	if r.HTTPResponse != nil {
   901  		return r.HTTPResponse.StatusCode
   902  	}
   903  	return 0
   904  }
   905  
   906  // GetEnvsWithResponse request returning *GetEnvsResponse
   907  func (c *ClientWithResponses) GetEnvsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetEnvsResponse, error) {
   908  	rsp, err := c.GetEnvs(ctx, reqEditors...)
   909  	if err != nil {
   910  		return nil, err
   911  	}
   912  	return ParseGetEnvsResponse(rsp)
   913  }
   914  
   915  // GetFilesWithResponse request returning *GetFilesResponse
   916  func (c *ClientWithResponses) GetFilesWithResponse(ctx context.Context, params *GetFilesParams, reqEditors ...RequestEditorFn) (*GetFilesResponse, error) {
   917  	rsp, err := c.GetFiles(ctx, params, reqEditors...)
   918  	if err != nil {
   919  		return nil, err
   920  	}
   921  	return ParseGetFilesResponse(rsp)
   922  }
   923  
   924  // PostFilesWithBodyWithResponse request with arbitrary body returning *PostFilesResponse
   925  func (c *ClientWithResponses) PostFilesWithBodyWithResponse(ctx context.Context, params *PostFilesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFilesResponse, error) {
   926  	rsp, err := c.PostFilesWithBody(ctx, params, contentType, body, reqEditors...)
   927  	if err != nil {
   928  		return nil, err
   929  	}
   930  	return ParsePostFilesResponse(rsp)
   931  }
   932  
   933  // GetHealthWithResponse request returning *GetHealthResponse
   934  func (c *ClientWithResponses) GetHealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHealthResponse, error) {
   935  	rsp, err := c.GetHealth(ctx, reqEditors...)
   936  	if err != nil {
   937  		return nil, err
   938  	}
   939  	return ParseGetHealthResponse(rsp)
   940  }
   941  
   942  // PostInitWithBodyWithResponse request with arbitrary body returning *PostInitResponse
   943  func (c *ClientWithResponses) PostInitWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostInitResponse, error) {
   944  	rsp, err := c.PostInitWithBody(ctx, contentType, body, reqEditors...)
   945  	if err != nil {
   946  		return nil, err
   947  	}
   948  	return ParsePostInitResponse(rsp)
   949  }
   950  
   951  func (c *ClientWithResponses) PostInitWithResponse(ctx context.Context, body PostInitJSONRequestBody, reqEditors ...RequestEditorFn) (*PostInitResponse, error) {
   952  	rsp, err := c.PostInit(ctx, body, reqEditors...)
   953  	if err != nil {
   954  		return nil, err
   955  	}
   956  	return ParsePostInitResponse(rsp)
   957  }
   958  
   959  // GetMetricsWithResponse request returning *GetMetricsResponse
   960  func (c *ClientWithResponses) GetMetricsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetMetricsResponse, error) {
   961  	rsp, err := c.GetMetrics(ctx, reqEditors...)
   962  	if err != nil {
   963  		return nil, err
   964  	}
   965  	return ParseGetMetricsResponse(rsp)
   966  }
   967  
   968  // ParseGetEnvsResponse parses an HTTP response from a GetEnvsWithResponse call
   969  func ParseGetEnvsResponse(rsp *http.Response) (*GetEnvsResponse, error) {
   970  	bodyBytes, err := io.ReadAll(rsp.Body)
   971  	defer func() { _ = rsp.Body.Close() }()
   972  	if err != nil {
   973  		return nil, err
   974  	}
   975  
   976  	response := &GetEnvsResponse{
   977  		Body:         bodyBytes,
   978  		HTTPResponse: rsp,
   979  	}
   980  
   981  	switch {
   982  	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
   983  		var dest EnvVars
   984  		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
   985  			return nil, err
   986  		}
   987  		response.JSON200 = &dest
   988  
   989  	}
   990  
   991  	return response, nil
   992  }
   993  
   994  // ParseGetFilesResponse parses an HTTP response from a GetFilesWithResponse call
   995  func ParseGetFilesResponse(rsp *http.Response) (*GetFilesResponse, error) {
   996  	bodyBytes, err := io.ReadAll(rsp.Body)
   997  	defer func() { _ = rsp.Body.Close() }()
   998  	if err != nil {
   999  		return nil, err
  1000  	}
  1001  
  1002  	response := &GetFilesResponse{
  1003  		Body:         bodyBytes,
  1004  		HTTPResponse: rsp,
  1005  	}
  1006  
  1007  	switch {
  1008  	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
  1009  		var dest InvalidPath
  1010  		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1011  			return nil, err
  1012  		}
  1013  		response.JSON400 = &dest
  1014  
  1015  	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
  1016  		var dest InvalidUser
  1017  		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1018  			return nil, err
  1019  		}
  1020  		response.JSON401 = &dest
  1021  
  1022  	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
  1023  		var dest FileNotFound
  1024  		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1025  			return nil, err
  1026  		}
  1027  		response.JSON404 = &dest
  1028  
  1029  	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
  1030  		var dest InternalServerError
  1031  		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1032  			return nil, err
  1033  		}
  1034  		response.JSON500 = &dest
  1035  
  1036  	}
  1037  
  1038  	return response, nil
  1039  }
  1040  
  1041  // ParsePostFilesResponse parses an HTTP response from a PostFilesWithResponse call
  1042  func ParsePostFilesResponse(rsp *http.Response) (*PostFilesResponse, error) {
  1043  	bodyBytes, err := io.ReadAll(rsp.Body)
  1044  	defer func() { _ = rsp.Body.Close() }()
  1045  	if err != nil {
  1046  		return nil, err
  1047  	}
  1048  
  1049  	response := &PostFilesResponse{
  1050  		Body:         bodyBytes,
  1051  		HTTPResponse: rsp,
  1052  	}
  1053  
  1054  	switch {
  1055  	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1056  		var dest UploadSuccess
  1057  		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1058  			return nil, err
  1059  		}
  1060  		response.JSON200 = &dest
  1061  
  1062  	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
  1063  		var dest InvalidPath
  1064  		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1065  			return nil, err
  1066  		}
  1067  		response.JSON400 = &dest
  1068  
  1069  	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
  1070  		var dest InvalidUser
  1071  		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1072  			return nil, err
  1073  		}
  1074  		response.JSON401 = &dest
  1075  
  1076  	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
  1077  		var dest InternalServerError
  1078  		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1079  			return nil, err
  1080  		}
  1081  		response.JSON500 = &dest
  1082  
  1083  	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 507:
  1084  		var dest NotEnoughDiskSpace
  1085  		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1086  			return nil, err
  1087  		}
  1088  		response.JSON507 = &dest
  1089  
  1090  	}
  1091  
  1092  	return response, nil
  1093  }
  1094  
  1095  // ParseGetHealthResponse parses an HTTP response from a GetHealthWithResponse call
  1096  func ParseGetHealthResponse(rsp *http.Response) (*GetHealthResponse, error) {
  1097  	bodyBytes, err := io.ReadAll(rsp.Body)
  1098  	defer func() { _ = rsp.Body.Close() }()
  1099  	if err != nil {
  1100  		return nil, err
  1101  	}
  1102  
  1103  	response := &GetHealthResponse{
  1104  		Body:         bodyBytes,
  1105  		HTTPResponse: rsp,
  1106  	}
  1107  
  1108  	return response, nil
  1109  }
  1110  
  1111  // ParsePostInitResponse parses an HTTP response from a PostInitWithResponse call
  1112  func ParsePostInitResponse(rsp *http.Response) (*PostInitResponse, error) {
  1113  	bodyBytes, err := io.ReadAll(rsp.Body)
  1114  	defer func() { _ = rsp.Body.Close() }()
  1115  	if err != nil {
  1116  		return nil, err
  1117  	}
  1118  
  1119  	response := &PostInitResponse{
  1120  		Body:         bodyBytes,
  1121  		HTTPResponse: rsp,
  1122  	}
  1123  
  1124  	return response, nil
  1125  }
  1126  
  1127  // ParseGetMetricsResponse parses an HTTP response from a GetMetricsWithResponse call
  1128  func ParseGetMetricsResponse(rsp *http.Response) (*GetMetricsResponse, error) {
  1129  	bodyBytes, err := io.ReadAll(rsp.Body)
  1130  	defer func() { _ = rsp.Body.Close() }()
  1131  	if err != nil {
  1132  		return nil, err
  1133  	}
  1134  
  1135  	response := &GetMetricsResponse{
  1136  		Body:         bodyBytes,
  1137  		HTTPResponse: rsp,
  1138  	}
  1139  
  1140  	switch {
  1141  	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1142  		var dest Metrics
  1143  		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1144  			return nil, err
  1145  		}
  1146  		response.JSON200 = &dest
  1147  
  1148  	}
  1149  
  1150  	return response, nil
  1151  }