mirror of
https://github.com/juanfont/headscale.git
synced 2026-07-10 01:48:18 +09:00
b05f8875c3
Serve the v2 API over the local unix socket for the CLI and add the oauth-clients command that drives it.
4014 lines
126 KiB
Go
4014 lines
126 KiB
Go
// Package clientv2 provides primitives to interact with the openapi HTTP API.
|
|
//
|
|
// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.7.1 DO NOT EDIT.
|
|
package clientv2
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/oapi-codegen/runtime"
|
|
openapi_types "github.com/oapi-codegen/runtime/types"
|
|
)
|
|
|
|
const (
|
|
BasicAuthScopes basicAuthContextKey = "basicAuth.Scopes"
|
|
BearerAuthScopes bearerAuthContextKey = "bearerAuth.Scopes"
|
|
)
|
|
|
|
// CreateKeyRequest defines model for CreateKeyRequest.
|
|
type CreateKeyRequest struct {
|
|
Capabilities *KeyCapabilities `json:"capabilities,omitempty"`
|
|
Description *string `json:"description,omitempty"`
|
|
|
|
// ExpirySeconds Lifetime in seconds; defaults to 90 days. Auth keys only.
|
|
ExpirySeconds *int64 `json:"expirySeconds,omitempty"`
|
|
|
|
// KeyType Key kind: "auth" (default) or "client" (OAuth client).
|
|
KeyType *string `json:"keyType,omitempty"`
|
|
|
|
// Scopes OAuth scopes granted to the client. keyType=client only.
|
|
Scopes *[]string `json:"scopes,omitempty"`
|
|
|
|
// Tags Tags the client may assign. keyType=client only.
|
|
Tags *[]string `json:"tags,omitempty"`
|
|
}
|
|
|
|
// DeleteKeyOutputBody defines model for DeleteKeyOutputBody.
|
|
type DeleteKeyOutputBody = map[string]interface{}
|
|
|
|
// Device defines model for Device.
|
|
type Device struct {
|
|
Addresses []string `json:"addresses"`
|
|
AdvertisedRoutes *[]string `json:"advertisedRoutes,omitempty"`
|
|
Authorized bool `json:"authorized"`
|
|
ClientVersion string `json:"clientVersion"`
|
|
Created time.Time `json:"created"`
|
|
EnabledRoutes *[]string `json:"enabledRoutes,omitempty"`
|
|
Expires *time.Time `json:"expires,omitempty"`
|
|
Hostname string `json:"hostname"`
|
|
Id string `json:"id"`
|
|
IsEphemeral bool `json:"isEphemeral"`
|
|
KeyExpiryDisabled bool `json:"keyExpiryDisabled"`
|
|
LastSeen *time.Time `json:"lastSeen,omitempty"`
|
|
MachineKey string `json:"machineKey"`
|
|
Name string `json:"name"`
|
|
NodeId string `json:"nodeId"`
|
|
NodeKey string `json:"nodeKey"`
|
|
Os string `json:"os"`
|
|
Tags []string `json:"tags"`
|
|
UpdateAvailable bool `json:"updateAvailable"`
|
|
User string `json:"user"`
|
|
}
|
|
|
|
// DeviceRoutes defines model for DeviceRoutes.
|
|
type DeviceRoutes struct {
|
|
AdvertisedRoutes []string `json:"advertisedRoutes"`
|
|
EnabledRoutes []string `json:"enabledRoutes"`
|
|
}
|
|
|
|
// EmptyOutputBody defines model for EmptyOutputBody.
|
|
type EmptyOutputBody = map[string]interface{}
|
|
|
|
// ErrorDetail defines model for ErrorDetail.
|
|
type ErrorDetail struct {
|
|
// Location Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id'
|
|
Location *string `json:"location,omitempty"`
|
|
|
|
// Message Error message text
|
|
Message *string `json:"message,omitempty"`
|
|
|
|
// Value The value at the given location
|
|
Value interface{} `json:"value,omitempty"`
|
|
}
|
|
|
|
// ErrorModel defines model for ErrorModel.
|
|
type ErrorModel struct {
|
|
// Detail A human-readable explanation specific to this occurrence of the problem.
|
|
Detail *string `json:"detail,omitempty"`
|
|
|
|
// Errors Optional list of individual error details
|
|
Errors *[]ErrorDetail `json:"errors,omitempty"`
|
|
|
|
// Instance A URI reference that identifies the specific occurrence of the problem.
|
|
Instance *string `json:"instance,omitempty"`
|
|
|
|
// Status HTTP status code
|
|
Status *int64 `json:"status,omitempty"`
|
|
|
|
// Title A short, human-readable summary of the problem type. This value should not change between occurrences of the error.
|
|
Title *string `json:"title,omitempty"`
|
|
|
|
// Type A URI reference to human-readable documentation for the error.
|
|
Type *string `json:"type,omitempty"`
|
|
}
|
|
|
|
// Key defines model for Key.
|
|
type Key struct {
|
|
Capabilities KeyCapabilities `json:"capabilities"`
|
|
Created time.Time `json:"created"`
|
|
Description *string `json:"description,omitempty"`
|
|
Expires *time.Time `json:"expires,omitempty"`
|
|
ExpirySeconds *int64 `json:"expirySeconds,omitempty"`
|
|
Id string `json:"id"`
|
|
Invalid bool `json:"invalid"`
|
|
Key *string `json:"key,omitempty"`
|
|
KeyType string `json:"keyType"`
|
|
Revoked *time.Time `json:"revoked,omitempty"`
|
|
Scopes *[]string `json:"scopes,omitempty"`
|
|
Tags *[]string `json:"tags,omitempty"`
|
|
UserId *string `json:"userId,omitempty"`
|
|
}
|
|
|
|
// KeyCapabilities defines model for KeyCapabilities.
|
|
type KeyCapabilities struct {
|
|
Devices KeyDeviceCapabilities `json:"devices"`
|
|
}
|
|
|
|
// KeyDeviceCapabilities defines model for KeyDeviceCapabilities.
|
|
type KeyDeviceCapabilities struct {
|
|
Create KeyDeviceCreateCapabilities `json:"create"`
|
|
}
|
|
|
|
// KeyDeviceCreateCapabilities defines model for KeyDeviceCreateCapabilities.
|
|
type KeyDeviceCreateCapabilities struct {
|
|
Ephemeral bool `json:"ephemeral"`
|
|
Preauthorized bool `json:"preauthorized"`
|
|
Reusable bool `json:"reusable"`
|
|
Tags *[]string `json:"tags"`
|
|
}
|
|
|
|
// ListDevicesOutputBody defines model for ListDevicesOutputBody.
|
|
type ListDevicesOutputBody struct {
|
|
Devices []Device `json:"devices"`
|
|
}
|
|
|
|
// ListKeysOutputBody defines model for ListKeysOutputBody.
|
|
type ListKeysOutputBody struct {
|
|
Keys []Key `json:"keys"`
|
|
}
|
|
|
|
// ListUsersOutputBody defines model for ListUsersOutputBody.
|
|
type ListUsersOutputBody struct {
|
|
Users []User `json:"users"`
|
|
}
|
|
|
|
// SetAuthorizedRequest defines model for SetAuthorizedRequest.
|
|
type SetAuthorizedRequest struct {
|
|
Authorized bool `json:"authorized"`
|
|
}
|
|
|
|
// SetKeyRequest defines model for SetKeyRequest.
|
|
type SetKeyRequest struct {
|
|
KeyExpiryDisabled bool `json:"keyExpiryDisabled"`
|
|
}
|
|
|
|
// SetNameRequest defines model for SetNameRequest.
|
|
type SetNameRequest struct {
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// SetSubnetRoutesRequest defines model for SetSubnetRoutesRequest.
|
|
type SetSubnetRoutesRequest struct {
|
|
Routes []string `json:"routes"`
|
|
}
|
|
|
|
// SetTagsRequest defines model for SetTagsRequest.
|
|
type SetTagsRequest struct {
|
|
Tags *[]string `json:"tags"`
|
|
}
|
|
|
|
// TailnetSettings defines model for TailnetSettings.
|
|
type TailnetSettings struct {
|
|
AclsExternalLink string `json:"aclsExternalLink"`
|
|
AclsExternallyManagedOn bool `json:"aclsExternallyManagedOn"`
|
|
DevicesApprovalOn bool `json:"devicesApprovalOn"`
|
|
DevicesAutoUpdatesOn bool `json:"devicesAutoUpdatesOn"`
|
|
DevicesKeyDurationDays int64 `json:"devicesKeyDurationDays"`
|
|
HttpsEnabled bool `json:"httpsEnabled"`
|
|
NetworkFlowLoggingOn bool `json:"networkFlowLoggingOn"`
|
|
PostureIdentityCollectionOn bool `json:"postureIdentityCollectionOn"`
|
|
RegionalRoutingOn bool `json:"regionalRoutingOn"`
|
|
UsersApprovalOn bool `json:"usersApprovalOn"`
|
|
UsersRoleAllowedToJoinExternalTailnets string `json:"usersRoleAllowedToJoinExternalTailnets"`
|
|
}
|
|
|
|
// User defines model for User.
|
|
type User struct {
|
|
Created time.Time `json:"created"`
|
|
CurrentlyConnected bool `json:"currentlyConnected"`
|
|
DeviceCount int64 `json:"deviceCount"`
|
|
DisplayName string `json:"displayName"`
|
|
Id string `json:"id"`
|
|
LastSeen time.Time `json:"lastSeen"`
|
|
LoginName string `json:"loginName"`
|
|
ProfilePicUrl string `json:"profilePicUrl"`
|
|
Role string `json:"role"`
|
|
Status string `json:"status"`
|
|
TailnetId string `json:"tailnetId"`
|
|
Type string `json:"type"`
|
|
}
|
|
|
|
// basicAuthContextKey is the context key for basicAuth security scheme
|
|
type basicAuthContextKey string
|
|
|
|
// bearerAuthContextKey is the context key for bearerAuth security scheme
|
|
type bearerAuthContextKey string
|
|
|
|
// DeleteDeviceParams defines parameters for DeleteDevice.
|
|
type DeleteDeviceParams struct {
|
|
// Fields Set to "all" for route fields.
|
|
Fields *string `form:"fields,omitempty" json:"fields,omitempty"`
|
|
}
|
|
|
|
// GetDeviceParams defines parameters for GetDevice.
|
|
type GetDeviceParams struct {
|
|
// Fields Set to "all" for route fields.
|
|
Fields *string `form:"fields,omitempty" json:"fields,omitempty"`
|
|
}
|
|
|
|
// GetDeviceRoutesParams defines parameters for GetDeviceRoutes.
|
|
type GetDeviceRoutesParams struct {
|
|
// Fields Set to "all" for route fields.
|
|
Fields *string `form:"fields,omitempty" json:"fields,omitempty"`
|
|
}
|
|
|
|
// GetACLParams defines parameters for GetACL.
|
|
type GetACLParams struct {
|
|
// Details Accepted for compatibility; ignored.
|
|
Details *bool `form:"details,omitempty" json:"details,omitempty"`
|
|
Accept *string `json:"Accept,omitempty"`
|
|
}
|
|
|
|
// SetACLJSONBody defines parameters for SetACL.
|
|
type SetACLJSONBody = openapi_types.File
|
|
|
|
// SetACLParams defines parameters for SetACL.
|
|
type SetACLParams struct {
|
|
IfMatch *string `json:"If-Match,omitempty"`
|
|
Accept *string `json:"Accept,omitempty"`
|
|
}
|
|
|
|
// ListDevicesParams defines parameters for ListDevices.
|
|
type ListDevicesParams struct {
|
|
Fields *string `form:"fields,omitempty" json:"fields,omitempty"`
|
|
}
|
|
|
|
// ListKeysParams defines parameters for ListKeys.
|
|
type ListKeysParams struct {
|
|
// All Accepted for compatibility; Headscale returns all keys.
|
|
All *bool `form:"all,omitempty" json:"all,omitempty"`
|
|
}
|
|
|
|
// UpdateTailnetSettingsJSONBody defines parameters for UpdateTailnetSettings.
|
|
type UpdateTailnetSettingsJSONBody = interface{}
|
|
|
|
// ListUsersParams defines parameters for ListUsers.
|
|
type ListUsersParams struct {
|
|
// Type Filter by user type; Headscale users are all "member".
|
|
Type *string `form:"type,omitempty" json:"type,omitempty"`
|
|
|
|
// Role Filter by user role; Headscale users are all "member".
|
|
Role *string `form:"role,omitempty" json:"role,omitempty"`
|
|
}
|
|
|
|
// AuthorizeDeviceJSONRequestBody defines body for AuthorizeDevice for application/json ContentType.
|
|
type AuthorizeDeviceJSONRequestBody = SetAuthorizedRequest
|
|
|
|
// SetDeviceKeyJSONRequestBody defines body for SetDeviceKey for application/json ContentType.
|
|
type SetDeviceKeyJSONRequestBody = SetKeyRequest
|
|
|
|
// SetDeviceNameJSONRequestBody defines body for SetDeviceName for application/json ContentType.
|
|
type SetDeviceNameJSONRequestBody = SetNameRequest
|
|
|
|
// SetDeviceRoutesJSONRequestBody defines body for SetDeviceRoutes for application/json ContentType.
|
|
type SetDeviceRoutesJSONRequestBody = SetSubnetRoutesRequest
|
|
|
|
// SetDeviceTagsJSONRequestBody defines body for SetDeviceTags for application/json ContentType.
|
|
type SetDeviceTagsJSONRequestBody = SetTagsRequest
|
|
|
|
// SetACLJSONRequestBody defines body for SetACL for application/json ContentType.
|
|
type SetACLJSONRequestBody = SetACLJSONBody
|
|
|
|
// CreateKeyJSONRequestBody defines body for CreateKey for application/json ContentType.
|
|
type CreateKeyJSONRequestBody = CreateKeyRequest
|
|
|
|
// UpdateTailnetSettingsJSONRequestBody defines body for UpdateTailnetSettings for application/json ContentType.
|
|
type UpdateTailnetSettingsJSONRequestBody = UpdateTailnetSettingsJSONBody
|
|
|
|
// RequestEditorFn is the function signature for the RequestEditor callback function
|
|
type RequestEditorFn func(ctx context.Context, req *http.Request) error
|
|
|
|
// Doer performs HTTP requests.
|
|
//
|
|
// The standard http.Client implements this interface.
|
|
type HttpRequestDoer interface {
|
|
Do(req *http.Request) (*http.Response, error)
|
|
}
|
|
|
|
// Client which conforms to the OpenAPI3 specification for this service.
|
|
type Client struct {
|
|
// The endpoint of the server conforming to this interface, with scheme,
|
|
// https://api.deepmap.com for example. This can contain a path relative
|
|
// to the server, such as https://api.deepmap.com/dev-test, and all the
|
|
// paths in the swagger spec will be appended to the server.
|
|
Server string
|
|
|
|
// Doer for performing requests, typically a *http.Client with any
|
|
// customized settings, such as certificate chains.
|
|
Client HttpRequestDoer
|
|
|
|
// A list of callbacks for modifying requests which are generated before sending over
|
|
// the network.
|
|
RequestEditors []RequestEditorFn
|
|
}
|
|
|
|
// ClientOption allows setting custom parameters during construction
|
|
type ClientOption func(*Client) error
|
|
|
|
// Creates a new Client, with reasonable defaults
|
|
func NewClient(server string, opts ...ClientOption) (*Client, error) {
|
|
// create a client with sane default values
|
|
client := Client{
|
|
Server: server,
|
|
}
|
|
// mutate client and add all optional params
|
|
for _, o := range opts {
|
|
if err := o(&client); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
// ensure the server URL always has a trailing slash
|
|
if !strings.HasSuffix(client.Server, "/") {
|
|
client.Server += "/"
|
|
}
|
|
// create httpClient, if not already present
|
|
if client.Client == nil {
|
|
client.Client = &http.Client{}
|
|
}
|
|
return &client, nil
|
|
}
|
|
|
|
// WithHTTPClient allows overriding the default Doer, which is
|
|
// automatically created using http.Client. This is useful for tests.
|
|
func WithHTTPClient(doer HttpRequestDoer) ClientOption {
|
|
return func(c *Client) error {
|
|
c.Client = doer
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithRequestEditorFn allows setting up a callback function, which will be
|
|
// called right before sending the request. This can be used to mutate the request.
|
|
func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
|
|
return func(c *Client) error {
|
|
c.RequestEditors = append(c.RequestEditors, fn)
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// The interface specification for the client above.
|
|
type ClientInterface interface {
|
|
// DeleteDevice request
|
|
DeleteDevice(ctx context.Context, id string, params *DeleteDeviceParams, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// GetDevice request
|
|
GetDevice(ctx context.Context, id string, params *GetDeviceParams, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// AuthorizeDeviceWithBody request with any body
|
|
AuthorizeDeviceWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
AuthorizeDevice(ctx context.Context, id string, body AuthorizeDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// SetDeviceKeyWithBody request with any body
|
|
SetDeviceKeyWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
SetDeviceKey(ctx context.Context, id string, body SetDeviceKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// SetDeviceNameWithBody request with any body
|
|
SetDeviceNameWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
SetDeviceName(ctx context.Context, id string, body SetDeviceNameJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// GetDeviceRoutes request
|
|
GetDeviceRoutes(ctx context.Context, id string, params *GetDeviceRoutesParams, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// SetDeviceRoutesWithBody request with any body
|
|
SetDeviceRoutesWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
SetDeviceRoutes(ctx context.Context, id string, body SetDeviceRoutesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// SetDeviceTagsWithBody request with any body
|
|
SetDeviceTagsWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
SetDeviceTags(ctx context.Context, id string, body SetDeviceTagsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// GetACL request
|
|
GetACL(ctx context.Context, tailnet string, params *GetACLParams, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// SetACLWithBody request with any body
|
|
SetACLWithBody(ctx context.Context, tailnet string, params *SetACLParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
SetACL(ctx context.Context, tailnet string, params *SetACLParams, body SetACLJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// ListDevices request
|
|
ListDevices(ctx context.Context, tailnet string, params *ListDevicesParams, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// ListKeys request
|
|
ListKeys(ctx context.Context, tailnet string, params *ListKeysParams, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// CreateKeyWithBody request with any body
|
|
CreateKeyWithBody(ctx context.Context, tailnet string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
CreateKey(ctx context.Context, tailnet string, body CreateKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// DeleteKey request
|
|
DeleteKey(ctx context.Context, tailnet string, keyId string, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// GetKey request
|
|
GetKey(ctx context.Context, tailnet string, keyId string, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// GetTailnetSettings request
|
|
GetTailnetSettings(ctx context.Context, tailnet string, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// UpdateTailnetSettingsWithBody request with any body
|
|
UpdateTailnetSettingsWithBody(ctx context.Context, tailnet string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
UpdateTailnetSettings(ctx context.Context, tailnet string, body UpdateTailnetSettingsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// ListUsers request
|
|
ListUsers(ctx context.Context, tailnet string, params *ListUsersParams, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// GetUser request
|
|
GetUser(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
}
|
|
|
|
func (c *Client) DeleteDevice(ctx context.Context, id string, params *DeleteDeviceParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewDeleteDeviceRequest(c.Server, id, params)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) GetDevice(ctx context.Context, id string, params *GetDeviceParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewGetDeviceRequest(c.Server, id, params)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) AuthorizeDeviceWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewAuthorizeDeviceRequestWithBody(c.Server, id, contentType, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) AuthorizeDevice(ctx context.Context, id string, body AuthorizeDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewAuthorizeDeviceRequest(c.Server, id, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) SetDeviceKeyWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewSetDeviceKeyRequestWithBody(c.Server, id, contentType, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) SetDeviceKey(ctx context.Context, id string, body SetDeviceKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewSetDeviceKeyRequest(c.Server, id, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) SetDeviceNameWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewSetDeviceNameRequestWithBody(c.Server, id, contentType, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) SetDeviceName(ctx context.Context, id string, body SetDeviceNameJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewSetDeviceNameRequest(c.Server, id, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) GetDeviceRoutes(ctx context.Context, id string, params *GetDeviceRoutesParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewGetDeviceRoutesRequest(c.Server, id, params)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) SetDeviceRoutesWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewSetDeviceRoutesRequestWithBody(c.Server, id, contentType, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) SetDeviceRoutes(ctx context.Context, id string, body SetDeviceRoutesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewSetDeviceRoutesRequest(c.Server, id, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) SetDeviceTagsWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewSetDeviceTagsRequestWithBody(c.Server, id, contentType, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) SetDeviceTags(ctx context.Context, id string, body SetDeviceTagsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewSetDeviceTagsRequest(c.Server, id, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) GetACL(ctx context.Context, tailnet string, params *GetACLParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewGetACLRequest(c.Server, tailnet, params)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) SetACLWithBody(ctx context.Context, tailnet string, params *SetACLParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewSetACLRequestWithBody(c.Server, tailnet, params, contentType, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) SetACL(ctx context.Context, tailnet string, params *SetACLParams, body SetACLJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewSetACLRequest(c.Server, tailnet, params, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) ListDevices(ctx context.Context, tailnet string, params *ListDevicesParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewListDevicesRequest(c.Server, tailnet, params)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) ListKeys(ctx context.Context, tailnet string, params *ListKeysParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewListKeysRequest(c.Server, tailnet, params)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) CreateKeyWithBody(ctx context.Context, tailnet string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewCreateKeyRequestWithBody(c.Server, tailnet, contentType, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) CreateKey(ctx context.Context, tailnet string, body CreateKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewCreateKeyRequest(c.Server, tailnet, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) DeleteKey(ctx context.Context, tailnet string, keyId string, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewDeleteKeyRequest(c.Server, tailnet, keyId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) GetKey(ctx context.Context, tailnet string, keyId string, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewGetKeyRequest(c.Server, tailnet, keyId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) GetTailnetSettings(ctx context.Context, tailnet string, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewGetTailnetSettingsRequest(c.Server, tailnet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) UpdateTailnetSettingsWithBody(ctx context.Context, tailnet string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewUpdateTailnetSettingsRequestWithBody(c.Server, tailnet, contentType, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) UpdateTailnetSettings(ctx context.Context, tailnet string, body UpdateTailnetSettingsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewUpdateTailnetSettingsRequest(c.Server, tailnet, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) ListUsers(ctx context.Context, tailnet string, params *ListUsersParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewListUsersRequest(c.Server, tailnet, params)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) GetUser(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewGetUserRequest(c.Server, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
// NewDeleteDeviceRequest generates requests for DeleteDevice
|
|
func NewDeleteDeviceRequest(server string, id string, params *DeleteDeviceParams) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/device/%s", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if params != nil {
|
|
// queryValues collects non-styled parameters (passthrough, JSON)
|
|
// that are safe to round-trip through url.Values.Encode().
|
|
queryValues := queryURL.Query()
|
|
// rawQueryFragments collects pre-encoded query fragments from
|
|
// styled parameters, preserving literal commas as delimiters
|
|
// per the OpenAPI spec (e.g. "color=blue,black,brown").
|
|
var rawQueryFragments []string
|
|
|
|
if params.Fields != nil {
|
|
|
|
if queryFrag, err := runtime.StyleParamWithOptions("form", false, "fields", *params.Fields, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil {
|
|
return nil, err
|
|
} else {
|
|
for _, qp := range strings.Split(queryFrag, "&") {
|
|
rawQueryFragments = append(rawQueryFragments, qp)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if encoded := queryValues.Encode(); encoded != "" {
|
|
rawQueryFragments = append(rawQueryFragments, encoded)
|
|
}
|
|
queryURL.RawQuery = strings.Join(rawQueryFragments, "&")
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewGetDeviceRequest generates requests for GetDevice
|
|
func NewGetDeviceRequest(server string, id string, params *GetDeviceParams) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/device/%s", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if params != nil {
|
|
// queryValues collects non-styled parameters (passthrough, JSON)
|
|
// that are safe to round-trip through url.Values.Encode().
|
|
queryValues := queryURL.Query()
|
|
// rawQueryFragments collects pre-encoded query fragments from
|
|
// styled parameters, preserving literal commas as delimiters
|
|
// per the OpenAPI spec (e.g. "color=blue,black,brown").
|
|
var rawQueryFragments []string
|
|
|
|
if params.Fields != nil {
|
|
|
|
if queryFrag, err := runtime.StyleParamWithOptions("form", false, "fields", *params.Fields, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil {
|
|
return nil, err
|
|
} else {
|
|
for _, qp := range strings.Split(queryFrag, "&") {
|
|
rawQueryFragments = append(rawQueryFragments, qp)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if encoded := queryValues.Encode(); encoded != "" {
|
|
rawQueryFragments = append(rawQueryFragments, encoded)
|
|
}
|
|
queryURL.RawQuery = strings.Join(rawQueryFragments, "&")
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewAuthorizeDeviceRequest calls the generic AuthorizeDevice builder with application/json body
|
|
func NewAuthorizeDeviceRequest(server string, id string, body AuthorizeDeviceJSONRequestBody) (*http.Request, error) {
|
|
var bodyReader io.Reader
|
|
buf, err := json.Marshal(body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
bodyReader = bytes.NewReader(buf)
|
|
return NewAuthorizeDeviceRequestWithBody(server, id, "application/json", bodyReader)
|
|
}
|
|
|
|
// NewAuthorizeDeviceRequestWithBody generates requests for AuthorizeDevice with any type of body
|
|
func NewAuthorizeDeviceRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/device/%s/authorized", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodPost, queryURL.String(), body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Add("Content-Type", contentType)
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewSetDeviceKeyRequest calls the generic SetDeviceKey builder with application/json body
|
|
func NewSetDeviceKeyRequest(server string, id string, body SetDeviceKeyJSONRequestBody) (*http.Request, error) {
|
|
var bodyReader io.Reader
|
|
buf, err := json.Marshal(body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
bodyReader = bytes.NewReader(buf)
|
|
return NewSetDeviceKeyRequestWithBody(server, id, "application/json", bodyReader)
|
|
}
|
|
|
|
// NewSetDeviceKeyRequestWithBody generates requests for SetDeviceKey with any type of body
|
|
func NewSetDeviceKeyRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/device/%s/key", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodPost, queryURL.String(), body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Add("Content-Type", contentType)
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewSetDeviceNameRequest calls the generic SetDeviceName builder with application/json body
|
|
func NewSetDeviceNameRequest(server string, id string, body SetDeviceNameJSONRequestBody) (*http.Request, error) {
|
|
var bodyReader io.Reader
|
|
buf, err := json.Marshal(body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
bodyReader = bytes.NewReader(buf)
|
|
return NewSetDeviceNameRequestWithBody(server, id, "application/json", bodyReader)
|
|
}
|
|
|
|
// NewSetDeviceNameRequestWithBody generates requests for SetDeviceName with any type of body
|
|
func NewSetDeviceNameRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/device/%s/name", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodPost, queryURL.String(), body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Add("Content-Type", contentType)
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewGetDeviceRoutesRequest generates requests for GetDeviceRoutes
|
|
func NewGetDeviceRoutesRequest(server string, id string, params *GetDeviceRoutesParams) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/device/%s/routes", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if params != nil {
|
|
// queryValues collects non-styled parameters (passthrough, JSON)
|
|
// that are safe to round-trip through url.Values.Encode().
|
|
queryValues := queryURL.Query()
|
|
// rawQueryFragments collects pre-encoded query fragments from
|
|
// styled parameters, preserving literal commas as delimiters
|
|
// per the OpenAPI spec (e.g. "color=blue,black,brown").
|
|
var rawQueryFragments []string
|
|
|
|
if params.Fields != nil {
|
|
|
|
if queryFrag, err := runtime.StyleParamWithOptions("form", false, "fields", *params.Fields, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil {
|
|
return nil, err
|
|
} else {
|
|
for _, qp := range strings.Split(queryFrag, "&") {
|
|
rawQueryFragments = append(rawQueryFragments, qp)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if encoded := queryValues.Encode(); encoded != "" {
|
|
rawQueryFragments = append(rawQueryFragments, encoded)
|
|
}
|
|
queryURL.RawQuery = strings.Join(rawQueryFragments, "&")
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewSetDeviceRoutesRequest calls the generic SetDeviceRoutes builder with application/json body
|
|
func NewSetDeviceRoutesRequest(server string, id string, body SetDeviceRoutesJSONRequestBody) (*http.Request, error) {
|
|
var bodyReader io.Reader
|
|
buf, err := json.Marshal(body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
bodyReader = bytes.NewReader(buf)
|
|
return NewSetDeviceRoutesRequestWithBody(server, id, "application/json", bodyReader)
|
|
}
|
|
|
|
// NewSetDeviceRoutesRequestWithBody generates requests for SetDeviceRoutes with any type of body
|
|
func NewSetDeviceRoutesRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/device/%s/routes", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodPost, queryURL.String(), body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Add("Content-Type", contentType)
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewSetDeviceTagsRequest calls the generic SetDeviceTags builder with application/json body
|
|
func NewSetDeviceTagsRequest(server string, id string, body SetDeviceTagsJSONRequestBody) (*http.Request, error) {
|
|
var bodyReader io.Reader
|
|
buf, err := json.Marshal(body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
bodyReader = bytes.NewReader(buf)
|
|
return NewSetDeviceTagsRequestWithBody(server, id, "application/json", bodyReader)
|
|
}
|
|
|
|
// NewSetDeviceTagsRequestWithBody generates requests for SetDeviceTags with any type of body
|
|
func NewSetDeviceTagsRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/device/%s/tags", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodPost, queryURL.String(), body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Add("Content-Type", contentType)
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewGetACLRequest generates requests for GetACL
|
|
func NewGetACLRequest(server string, tailnet string, params *GetACLParams) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "tailnet", tailnet, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/tailnet/%s/acl", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if params != nil {
|
|
// queryValues collects non-styled parameters (passthrough, JSON)
|
|
// that are safe to round-trip through url.Values.Encode().
|
|
queryValues := queryURL.Query()
|
|
// rawQueryFragments collects pre-encoded query fragments from
|
|
// styled parameters, preserving literal commas as delimiters
|
|
// per the OpenAPI spec (e.g. "color=blue,black,brown").
|
|
var rawQueryFragments []string
|
|
|
|
if params.Details != nil {
|
|
|
|
if queryFrag, err := runtime.StyleParamWithOptions("form", false, "details", *params.Details, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "boolean", Format: ""}); err != nil {
|
|
return nil, err
|
|
} else {
|
|
for _, qp := range strings.Split(queryFrag, "&") {
|
|
rawQueryFragments = append(rawQueryFragments, qp)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if encoded := queryValues.Encode(); encoded != "" {
|
|
rawQueryFragments = append(rawQueryFragments, encoded)
|
|
}
|
|
queryURL.RawQuery = strings.Join(rawQueryFragments, "&")
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if params != nil {
|
|
|
|
if params.Accept != nil {
|
|
var headerParam0 string
|
|
|
|
headerParam0, err = runtime.StyleParamWithOptions("simple", false, "Accept", *params.Accept, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationHeader, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Set("Accept", headerParam0)
|
|
}
|
|
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewSetACLRequest calls the generic SetACL builder with application/json body
|
|
func NewSetACLRequest(server string, tailnet string, params *SetACLParams, body SetACLJSONRequestBody) (*http.Request, error) {
|
|
var bodyReader io.Reader
|
|
buf, err := json.Marshal(body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
bodyReader = bytes.NewReader(buf)
|
|
return NewSetACLRequestWithBody(server, tailnet, params, "application/json", bodyReader)
|
|
}
|
|
|
|
// NewSetACLRequestWithBody generates requests for SetACL with any type of body
|
|
func NewSetACLRequestWithBody(server string, tailnet string, params *SetACLParams, contentType string, body io.Reader) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "tailnet", tailnet, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/tailnet/%s/acl", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodPost, queryURL.String(), body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Add("Content-Type", contentType)
|
|
|
|
if params != nil {
|
|
|
|
if params.IfMatch != nil {
|
|
var headerParam0 string
|
|
|
|
headerParam0, err = runtime.StyleParamWithOptions("simple", false, "If-Match", *params.IfMatch, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationHeader, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Set("If-Match", headerParam0)
|
|
}
|
|
|
|
if params.Accept != nil {
|
|
var headerParam1 string
|
|
|
|
headerParam1, err = runtime.StyleParamWithOptions("simple", false, "Accept", *params.Accept, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationHeader, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Set("Accept", headerParam1)
|
|
}
|
|
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewListDevicesRequest generates requests for ListDevices
|
|
func NewListDevicesRequest(server string, tailnet string, params *ListDevicesParams) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "tailnet", tailnet, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/tailnet/%s/devices", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if params != nil {
|
|
// queryValues collects non-styled parameters (passthrough, JSON)
|
|
// that are safe to round-trip through url.Values.Encode().
|
|
queryValues := queryURL.Query()
|
|
// rawQueryFragments collects pre-encoded query fragments from
|
|
// styled parameters, preserving literal commas as delimiters
|
|
// per the OpenAPI spec (e.g. "color=blue,black,brown").
|
|
var rawQueryFragments []string
|
|
|
|
if params.Fields != nil {
|
|
|
|
if queryFrag, err := runtime.StyleParamWithOptions("form", false, "fields", *params.Fields, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil {
|
|
return nil, err
|
|
} else {
|
|
for _, qp := range strings.Split(queryFrag, "&") {
|
|
rawQueryFragments = append(rawQueryFragments, qp)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if encoded := queryValues.Encode(); encoded != "" {
|
|
rawQueryFragments = append(rawQueryFragments, encoded)
|
|
}
|
|
queryURL.RawQuery = strings.Join(rawQueryFragments, "&")
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewListKeysRequest generates requests for ListKeys
|
|
func NewListKeysRequest(server string, tailnet string, params *ListKeysParams) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "tailnet", tailnet, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/tailnet/%s/keys", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if params != nil {
|
|
// queryValues collects non-styled parameters (passthrough, JSON)
|
|
// that are safe to round-trip through url.Values.Encode().
|
|
queryValues := queryURL.Query()
|
|
// rawQueryFragments collects pre-encoded query fragments from
|
|
// styled parameters, preserving literal commas as delimiters
|
|
// per the OpenAPI spec (e.g. "color=blue,black,brown").
|
|
var rawQueryFragments []string
|
|
|
|
if params.All != nil {
|
|
|
|
if queryFrag, err := runtime.StyleParamWithOptions("form", false, "all", *params.All, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "boolean", Format: ""}); err != nil {
|
|
return nil, err
|
|
} else {
|
|
for _, qp := range strings.Split(queryFrag, "&") {
|
|
rawQueryFragments = append(rawQueryFragments, qp)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if encoded := queryValues.Encode(); encoded != "" {
|
|
rawQueryFragments = append(rawQueryFragments, encoded)
|
|
}
|
|
queryURL.RawQuery = strings.Join(rawQueryFragments, "&")
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewCreateKeyRequest calls the generic CreateKey builder with application/json body
|
|
func NewCreateKeyRequest(server string, tailnet string, body CreateKeyJSONRequestBody) (*http.Request, error) {
|
|
var bodyReader io.Reader
|
|
buf, err := json.Marshal(body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
bodyReader = bytes.NewReader(buf)
|
|
return NewCreateKeyRequestWithBody(server, tailnet, "application/json", bodyReader)
|
|
}
|
|
|
|
// NewCreateKeyRequestWithBody generates requests for CreateKey with any type of body
|
|
func NewCreateKeyRequestWithBody(server string, tailnet string, contentType string, body io.Reader) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "tailnet", tailnet, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/tailnet/%s/keys", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodPost, queryURL.String(), body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Add("Content-Type", contentType)
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewDeleteKeyRequest generates requests for DeleteKey
|
|
func NewDeleteKeyRequest(server string, tailnet string, keyId string) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "tailnet", tailnet, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var pathParam1 string
|
|
|
|
pathParam1, err = runtime.StyleParamWithOptions("simple", false, "keyId", keyId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/tailnet/%s/keys/%s", pathParam0, pathParam1)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewGetKeyRequest generates requests for GetKey
|
|
func NewGetKeyRequest(server string, tailnet string, keyId string) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "tailnet", tailnet, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var pathParam1 string
|
|
|
|
pathParam1, err = runtime.StyleParamWithOptions("simple", false, "keyId", keyId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/tailnet/%s/keys/%s", pathParam0, pathParam1)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewGetTailnetSettingsRequest generates requests for GetTailnetSettings
|
|
func NewGetTailnetSettingsRequest(server string, tailnet string) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "tailnet", tailnet, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/tailnet/%s/settings", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewUpdateTailnetSettingsRequest calls the generic UpdateTailnetSettings builder with application/json body
|
|
func NewUpdateTailnetSettingsRequest(server string, tailnet string, body UpdateTailnetSettingsJSONRequestBody) (*http.Request, error) {
|
|
var bodyReader io.Reader
|
|
buf, err := json.Marshal(body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
bodyReader = bytes.NewReader(buf)
|
|
return NewUpdateTailnetSettingsRequestWithBody(server, tailnet, "application/json", bodyReader)
|
|
}
|
|
|
|
// NewUpdateTailnetSettingsRequestWithBody generates requests for UpdateTailnetSettings with any type of body
|
|
func NewUpdateTailnetSettingsRequestWithBody(server string, tailnet string, contentType string, body io.Reader) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "tailnet", tailnet, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/tailnet/%s/settings", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodPatch, queryURL.String(), body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Add("Content-Type", contentType)
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewListUsersRequest generates requests for ListUsers
|
|
func NewListUsersRequest(server string, tailnet string, params *ListUsersParams) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "tailnet", tailnet, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/tailnet/%s/users", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if params != nil {
|
|
// queryValues collects non-styled parameters (passthrough, JSON)
|
|
// that are safe to round-trip through url.Values.Encode().
|
|
queryValues := queryURL.Query()
|
|
// rawQueryFragments collects pre-encoded query fragments from
|
|
// styled parameters, preserving literal commas as delimiters
|
|
// per the OpenAPI spec (e.g. "color=blue,black,brown").
|
|
var rawQueryFragments []string
|
|
|
|
if params.Type != nil {
|
|
|
|
if queryFrag, err := runtime.StyleParamWithOptions("form", false, "type", *params.Type, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil {
|
|
return nil, err
|
|
} else {
|
|
for _, qp := range strings.Split(queryFrag, "&") {
|
|
rawQueryFragments = append(rawQueryFragments, qp)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if params.Role != nil {
|
|
|
|
if queryFrag, err := runtime.StyleParamWithOptions("form", false, "role", *params.Role, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil {
|
|
return nil, err
|
|
} else {
|
|
for _, qp := range strings.Split(queryFrag, "&") {
|
|
rawQueryFragments = append(rawQueryFragments, qp)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if encoded := queryValues.Encode(); encoded != "" {
|
|
rawQueryFragments = append(rawQueryFragments, encoded)
|
|
}
|
|
queryURL.RawQuery = strings.Join(rawQueryFragments, "&")
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewGetUserRequest generates requests for GetUser
|
|
func NewGetUserRequest(server string, id string) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/api/v2/users/%s", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error {
|
|
for _, r := range c.RequestEditors {
|
|
if err := r(ctx, req); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
for _, r := range additionalEditors {
|
|
if err := r(ctx, req); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ClientWithResponses builds on ClientInterface to offer response payloads
|
|
type ClientWithResponses struct {
|
|
ClientInterface
|
|
}
|
|
|
|
// NewClientWithResponses creates a new ClientWithResponses, which wraps
|
|
// Client with return type handling
|
|
func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
|
|
client, err := NewClient(server, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &ClientWithResponses{client}, nil
|
|
}
|
|
|
|
// WithBaseURL overrides the baseURL.
|
|
func WithBaseURL(baseURL string) ClientOption {
|
|
return func(c *Client) error {
|
|
newBaseURL, err := url.Parse(baseURL)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
c.Server = newBaseURL.String()
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// ClientWithResponsesInterface is the interface specification for the client with responses above.
|
|
type ClientWithResponsesInterface interface {
|
|
// DeleteDeviceWithResponse request
|
|
DeleteDeviceWithResponse(ctx context.Context, id string, params *DeleteDeviceParams, reqEditors ...RequestEditorFn) (*DeleteDeviceResponse, error)
|
|
|
|
// GetDeviceWithResponse request
|
|
GetDeviceWithResponse(ctx context.Context, id string, params *GetDeviceParams, reqEditors ...RequestEditorFn) (*GetDeviceResponse, error)
|
|
|
|
// AuthorizeDeviceWithBodyWithResponse request with any body
|
|
AuthorizeDeviceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthorizeDeviceResponse, error)
|
|
|
|
AuthorizeDeviceWithResponse(ctx context.Context, id string, body AuthorizeDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthorizeDeviceResponse, error)
|
|
|
|
// SetDeviceKeyWithBodyWithResponse request with any body
|
|
SetDeviceKeyWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetDeviceKeyResponse, error)
|
|
|
|
SetDeviceKeyWithResponse(ctx context.Context, id string, body SetDeviceKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*SetDeviceKeyResponse, error)
|
|
|
|
// SetDeviceNameWithBodyWithResponse request with any body
|
|
SetDeviceNameWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetDeviceNameResponse, error)
|
|
|
|
SetDeviceNameWithResponse(ctx context.Context, id string, body SetDeviceNameJSONRequestBody, reqEditors ...RequestEditorFn) (*SetDeviceNameResponse, error)
|
|
|
|
// GetDeviceRoutesWithResponse request
|
|
GetDeviceRoutesWithResponse(ctx context.Context, id string, params *GetDeviceRoutesParams, reqEditors ...RequestEditorFn) (*GetDeviceRoutesResponse, error)
|
|
|
|
// SetDeviceRoutesWithBodyWithResponse request with any body
|
|
SetDeviceRoutesWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetDeviceRoutesResponse, error)
|
|
|
|
SetDeviceRoutesWithResponse(ctx context.Context, id string, body SetDeviceRoutesJSONRequestBody, reqEditors ...RequestEditorFn) (*SetDeviceRoutesResponse, error)
|
|
|
|
// SetDeviceTagsWithBodyWithResponse request with any body
|
|
SetDeviceTagsWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetDeviceTagsResponse, error)
|
|
|
|
SetDeviceTagsWithResponse(ctx context.Context, id string, body SetDeviceTagsJSONRequestBody, reqEditors ...RequestEditorFn) (*SetDeviceTagsResponse, error)
|
|
|
|
// GetACLWithResponse request
|
|
GetACLWithResponse(ctx context.Context, tailnet string, params *GetACLParams, reqEditors ...RequestEditorFn) (*GetACLResponse, error)
|
|
|
|
// SetACLWithBodyWithResponse request with any body
|
|
SetACLWithBodyWithResponse(ctx context.Context, tailnet string, params *SetACLParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetACLResponse, error)
|
|
|
|
SetACLWithResponse(ctx context.Context, tailnet string, params *SetACLParams, body SetACLJSONRequestBody, reqEditors ...RequestEditorFn) (*SetACLResponse, error)
|
|
|
|
// ListDevicesWithResponse request
|
|
ListDevicesWithResponse(ctx context.Context, tailnet string, params *ListDevicesParams, reqEditors ...RequestEditorFn) (*ListDevicesResponse, error)
|
|
|
|
// ListKeysWithResponse request
|
|
ListKeysWithResponse(ctx context.Context, tailnet string, params *ListKeysParams, reqEditors ...RequestEditorFn) (*ListKeysResponse, error)
|
|
|
|
// CreateKeyWithBodyWithResponse request with any body
|
|
CreateKeyWithBodyWithResponse(ctx context.Context, tailnet string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateKeyResponse, error)
|
|
|
|
CreateKeyWithResponse(ctx context.Context, tailnet string, body CreateKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateKeyResponse, error)
|
|
|
|
// DeleteKeyWithResponse request
|
|
DeleteKeyWithResponse(ctx context.Context, tailnet string, keyId string, reqEditors ...RequestEditorFn) (*DeleteKeyResponse, error)
|
|
|
|
// GetKeyWithResponse request
|
|
GetKeyWithResponse(ctx context.Context, tailnet string, keyId string, reqEditors ...RequestEditorFn) (*GetKeyResponse, error)
|
|
|
|
// GetTailnetSettingsWithResponse request
|
|
GetTailnetSettingsWithResponse(ctx context.Context, tailnet string, reqEditors ...RequestEditorFn) (*GetTailnetSettingsResponse, error)
|
|
|
|
// UpdateTailnetSettingsWithBodyWithResponse request with any body
|
|
UpdateTailnetSettingsWithBodyWithResponse(ctx context.Context, tailnet string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateTailnetSettingsResponse, error)
|
|
|
|
UpdateTailnetSettingsWithResponse(ctx context.Context, tailnet string, body UpdateTailnetSettingsJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateTailnetSettingsResponse, error)
|
|
|
|
// ListUsersWithResponse request
|
|
ListUsersWithResponse(ctx context.Context, tailnet string, params *ListUsersParams, reqEditors ...RequestEditorFn) (*ListUsersResponse, error)
|
|
|
|
// GetUserWithResponse request
|
|
GetUserWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetUserResponse, error)
|
|
}
|
|
|
|
type DeleteDeviceResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *EmptyOutputBody
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r DeleteDeviceResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r DeleteDeviceResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r DeleteDeviceResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type GetDeviceResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *Device
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r GetDeviceResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r GetDeviceResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r GetDeviceResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type AuthorizeDeviceResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *EmptyOutputBody
|
|
ApplicationproblemJSON400 *ErrorModel
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r AuthorizeDeviceResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r AuthorizeDeviceResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r AuthorizeDeviceResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type SetDeviceKeyResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *EmptyOutputBody
|
|
ApplicationproblemJSON400 *ErrorModel
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r SetDeviceKeyResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r SetDeviceKeyResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r SetDeviceKeyResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type SetDeviceNameResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *EmptyOutputBody
|
|
ApplicationproblemJSON400 *ErrorModel
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r SetDeviceNameResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r SetDeviceNameResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r SetDeviceNameResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type GetDeviceRoutesResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *DeviceRoutes
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r GetDeviceRoutesResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r GetDeviceRoutesResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r GetDeviceRoutesResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type SetDeviceRoutesResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *DeviceRoutes
|
|
ApplicationproblemJSON400 *ErrorModel
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r SetDeviceRoutesResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r SetDeviceRoutesResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r SetDeviceRoutesResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type SetDeviceTagsResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *EmptyOutputBody
|
|
ApplicationproblemJSON400 *ErrorModel
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r SetDeviceTagsResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r SetDeviceTagsResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r SetDeviceTagsResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type GetACLResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r GetACLResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r GetACLResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r GetACLResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type SetACLResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
ApplicationproblemJSON400 *ErrorModel
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON412 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r SetACLResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r SetACLResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r SetACLResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type ListDevicesResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *ListDevicesOutputBody
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r ListDevicesResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r ListDevicesResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r ListDevicesResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type ListKeysResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *ListKeysOutputBody
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r ListKeysResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r ListKeysResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r ListKeysResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type CreateKeyResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *Key
|
|
ApplicationproblemJSON400 *ErrorModel
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r CreateKeyResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r CreateKeyResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r CreateKeyResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type DeleteKeyResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *DeleteKeyOutputBody
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r DeleteKeyResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r DeleteKeyResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r DeleteKeyResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type GetKeyResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *Key
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r GetKeyResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r GetKeyResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r GetKeyResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type GetTailnetSettingsResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *TailnetSettings
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r GetTailnetSettingsResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r GetTailnetSettingsResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r GetTailnetSettingsResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type UpdateTailnetSettingsResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *TailnetSettings
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
ApplicationproblemJSON501 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r UpdateTailnetSettingsResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r UpdateTailnetSettingsResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r UpdateTailnetSettingsResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type ListUsersResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *ListUsersOutputBody
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r ListUsersResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r ListUsersResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r ListUsersResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
type GetUserResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *User
|
|
ApplicationproblemJSON401 *ErrorModel
|
|
ApplicationproblemJSON403 *ErrorModel
|
|
ApplicationproblemJSON404 *ErrorModel
|
|
ApplicationproblemJSON422 *ErrorModel
|
|
ApplicationproblemJSON500 *ErrorModel
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r GetUserResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r GetUserResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
|
|
func (r GetUserResponse) ContentType() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Header.Get("Content-Type")
|
|
}
|
|
return ""
|
|
}
|
|
|
|
// DeleteDeviceWithResponse request returning *DeleteDeviceResponse
|
|
func (c *ClientWithResponses) DeleteDeviceWithResponse(ctx context.Context, id string, params *DeleteDeviceParams, reqEditors ...RequestEditorFn) (*DeleteDeviceResponse, error) {
|
|
rsp, err := c.DeleteDevice(ctx, id, params, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseDeleteDeviceResponse(rsp)
|
|
}
|
|
|
|
// GetDeviceWithResponse request returning *GetDeviceResponse
|
|
func (c *ClientWithResponses) GetDeviceWithResponse(ctx context.Context, id string, params *GetDeviceParams, reqEditors ...RequestEditorFn) (*GetDeviceResponse, error) {
|
|
rsp, err := c.GetDevice(ctx, id, params, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseGetDeviceResponse(rsp)
|
|
}
|
|
|
|
// AuthorizeDeviceWithBodyWithResponse request with arbitrary body returning *AuthorizeDeviceResponse
|
|
func (c *ClientWithResponses) AuthorizeDeviceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthorizeDeviceResponse, error) {
|
|
rsp, err := c.AuthorizeDeviceWithBody(ctx, id, contentType, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseAuthorizeDeviceResponse(rsp)
|
|
}
|
|
|
|
func (c *ClientWithResponses) AuthorizeDeviceWithResponse(ctx context.Context, id string, body AuthorizeDeviceJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthorizeDeviceResponse, error) {
|
|
rsp, err := c.AuthorizeDevice(ctx, id, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseAuthorizeDeviceResponse(rsp)
|
|
}
|
|
|
|
// SetDeviceKeyWithBodyWithResponse request with arbitrary body returning *SetDeviceKeyResponse
|
|
func (c *ClientWithResponses) SetDeviceKeyWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetDeviceKeyResponse, error) {
|
|
rsp, err := c.SetDeviceKeyWithBody(ctx, id, contentType, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseSetDeviceKeyResponse(rsp)
|
|
}
|
|
|
|
func (c *ClientWithResponses) SetDeviceKeyWithResponse(ctx context.Context, id string, body SetDeviceKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*SetDeviceKeyResponse, error) {
|
|
rsp, err := c.SetDeviceKey(ctx, id, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseSetDeviceKeyResponse(rsp)
|
|
}
|
|
|
|
// SetDeviceNameWithBodyWithResponse request with arbitrary body returning *SetDeviceNameResponse
|
|
func (c *ClientWithResponses) SetDeviceNameWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetDeviceNameResponse, error) {
|
|
rsp, err := c.SetDeviceNameWithBody(ctx, id, contentType, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseSetDeviceNameResponse(rsp)
|
|
}
|
|
|
|
func (c *ClientWithResponses) SetDeviceNameWithResponse(ctx context.Context, id string, body SetDeviceNameJSONRequestBody, reqEditors ...RequestEditorFn) (*SetDeviceNameResponse, error) {
|
|
rsp, err := c.SetDeviceName(ctx, id, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseSetDeviceNameResponse(rsp)
|
|
}
|
|
|
|
// GetDeviceRoutesWithResponse request returning *GetDeviceRoutesResponse
|
|
func (c *ClientWithResponses) GetDeviceRoutesWithResponse(ctx context.Context, id string, params *GetDeviceRoutesParams, reqEditors ...RequestEditorFn) (*GetDeviceRoutesResponse, error) {
|
|
rsp, err := c.GetDeviceRoutes(ctx, id, params, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseGetDeviceRoutesResponse(rsp)
|
|
}
|
|
|
|
// SetDeviceRoutesWithBodyWithResponse request with arbitrary body returning *SetDeviceRoutesResponse
|
|
func (c *ClientWithResponses) SetDeviceRoutesWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetDeviceRoutesResponse, error) {
|
|
rsp, err := c.SetDeviceRoutesWithBody(ctx, id, contentType, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseSetDeviceRoutesResponse(rsp)
|
|
}
|
|
|
|
func (c *ClientWithResponses) SetDeviceRoutesWithResponse(ctx context.Context, id string, body SetDeviceRoutesJSONRequestBody, reqEditors ...RequestEditorFn) (*SetDeviceRoutesResponse, error) {
|
|
rsp, err := c.SetDeviceRoutes(ctx, id, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseSetDeviceRoutesResponse(rsp)
|
|
}
|
|
|
|
// SetDeviceTagsWithBodyWithResponse request with arbitrary body returning *SetDeviceTagsResponse
|
|
func (c *ClientWithResponses) SetDeviceTagsWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetDeviceTagsResponse, error) {
|
|
rsp, err := c.SetDeviceTagsWithBody(ctx, id, contentType, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseSetDeviceTagsResponse(rsp)
|
|
}
|
|
|
|
func (c *ClientWithResponses) SetDeviceTagsWithResponse(ctx context.Context, id string, body SetDeviceTagsJSONRequestBody, reqEditors ...RequestEditorFn) (*SetDeviceTagsResponse, error) {
|
|
rsp, err := c.SetDeviceTags(ctx, id, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseSetDeviceTagsResponse(rsp)
|
|
}
|
|
|
|
// GetACLWithResponse request returning *GetACLResponse
|
|
func (c *ClientWithResponses) GetACLWithResponse(ctx context.Context, tailnet string, params *GetACLParams, reqEditors ...RequestEditorFn) (*GetACLResponse, error) {
|
|
rsp, err := c.GetACL(ctx, tailnet, params, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseGetACLResponse(rsp)
|
|
}
|
|
|
|
// SetACLWithBodyWithResponse request with arbitrary body returning *SetACLResponse
|
|
func (c *ClientWithResponses) SetACLWithBodyWithResponse(ctx context.Context, tailnet string, params *SetACLParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetACLResponse, error) {
|
|
rsp, err := c.SetACLWithBody(ctx, tailnet, params, contentType, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseSetACLResponse(rsp)
|
|
}
|
|
|
|
func (c *ClientWithResponses) SetACLWithResponse(ctx context.Context, tailnet string, params *SetACLParams, body SetACLJSONRequestBody, reqEditors ...RequestEditorFn) (*SetACLResponse, error) {
|
|
rsp, err := c.SetACL(ctx, tailnet, params, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseSetACLResponse(rsp)
|
|
}
|
|
|
|
// ListDevicesWithResponse request returning *ListDevicesResponse
|
|
func (c *ClientWithResponses) ListDevicesWithResponse(ctx context.Context, tailnet string, params *ListDevicesParams, reqEditors ...RequestEditorFn) (*ListDevicesResponse, error) {
|
|
rsp, err := c.ListDevices(ctx, tailnet, params, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseListDevicesResponse(rsp)
|
|
}
|
|
|
|
// ListKeysWithResponse request returning *ListKeysResponse
|
|
func (c *ClientWithResponses) ListKeysWithResponse(ctx context.Context, tailnet string, params *ListKeysParams, reqEditors ...RequestEditorFn) (*ListKeysResponse, error) {
|
|
rsp, err := c.ListKeys(ctx, tailnet, params, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseListKeysResponse(rsp)
|
|
}
|
|
|
|
// CreateKeyWithBodyWithResponse request with arbitrary body returning *CreateKeyResponse
|
|
func (c *ClientWithResponses) CreateKeyWithBodyWithResponse(ctx context.Context, tailnet string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateKeyResponse, error) {
|
|
rsp, err := c.CreateKeyWithBody(ctx, tailnet, contentType, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseCreateKeyResponse(rsp)
|
|
}
|
|
|
|
func (c *ClientWithResponses) CreateKeyWithResponse(ctx context.Context, tailnet string, body CreateKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateKeyResponse, error) {
|
|
rsp, err := c.CreateKey(ctx, tailnet, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseCreateKeyResponse(rsp)
|
|
}
|
|
|
|
// DeleteKeyWithResponse request returning *DeleteKeyResponse
|
|
func (c *ClientWithResponses) DeleteKeyWithResponse(ctx context.Context, tailnet string, keyId string, reqEditors ...RequestEditorFn) (*DeleteKeyResponse, error) {
|
|
rsp, err := c.DeleteKey(ctx, tailnet, keyId, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseDeleteKeyResponse(rsp)
|
|
}
|
|
|
|
// GetKeyWithResponse request returning *GetKeyResponse
|
|
func (c *ClientWithResponses) GetKeyWithResponse(ctx context.Context, tailnet string, keyId string, reqEditors ...RequestEditorFn) (*GetKeyResponse, error) {
|
|
rsp, err := c.GetKey(ctx, tailnet, keyId, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseGetKeyResponse(rsp)
|
|
}
|
|
|
|
// GetTailnetSettingsWithResponse request returning *GetTailnetSettingsResponse
|
|
func (c *ClientWithResponses) GetTailnetSettingsWithResponse(ctx context.Context, tailnet string, reqEditors ...RequestEditorFn) (*GetTailnetSettingsResponse, error) {
|
|
rsp, err := c.GetTailnetSettings(ctx, tailnet, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseGetTailnetSettingsResponse(rsp)
|
|
}
|
|
|
|
// UpdateTailnetSettingsWithBodyWithResponse request with arbitrary body returning *UpdateTailnetSettingsResponse
|
|
func (c *ClientWithResponses) UpdateTailnetSettingsWithBodyWithResponse(ctx context.Context, tailnet string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateTailnetSettingsResponse, error) {
|
|
rsp, err := c.UpdateTailnetSettingsWithBody(ctx, tailnet, contentType, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseUpdateTailnetSettingsResponse(rsp)
|
|
}
|
|
|
|
func (c *ClientWithResponses) UpdateTailnetSettingsWithResponse(ctx context.Context, tailnet string, body UpdateTailnetSettingsJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateTailnetSettingsResponse, error) {
|
|
rsp, err := c.UpdateTailnetSettings(ctx, tailnet, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseUpdateTailnetSettingsResponse(rsp)
|
|
}
|
|
|
|
// ListUsersWithResponse request returning *ListUsersResponse
|
|
func (c *ClientWithResponses) ListUsersWithResponse(ctx context.Context, tailnet string, params *ListUsersParams, reqEditors ...RequestEditorFn) (*ListUsersResponse, error) {
|
|
rsp, err := c.ListUsers(ctx, tailnet, params, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseListUsersResponse(rsp)
|
|
}
|
|
|
|
// GetUserWithResponse request returning *GetUserResponse
|
|
func (c *ClientWithResponses) GetUserWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetUserResponse, error) {
|
|
rsp, err := c.GetUser(ctx, id, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseGetUserResponse(rsp)
|
|
}
|
|
|
|
// ParseDeleteDeviceResponse parses an HTTP response from a DeleteDeviceWithResponse call
|
|
func ParseDeleteDeviceResponse(rsp *http.Response) (*DeleteDeviceResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &DeleteDeviceResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest EmptyOutputBody
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseGetDeviceResponse parses an HTTP response from a GetDeviceWithResponse call
|
|
func ParseGetDeviceResponse(rsp *http.Response) (*GetDeviceResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &GetDeviceResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest Device
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseAuthorizeDeviceResponse parses an HTTP response from a AuthorizeDeviceWithResponse call
|
|
func ParseAuthorizeDeviceResponse(rsp *http.Response) (*AuthorizeDeviceResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &AuthorizeDeviceResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest EmptyOutputBody
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON400 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseSetDeviceKeyResponse parses an HTTP response from a SetDeviceKeyWithResponse call
|
|
func ParseSetDeviceKeyResponse(rsp *http.Response) (*SetDeviceKeyResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &SetDeviceKeyResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest EmptyOutputBody
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON400 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseSetDeviceNameResponse parses an HTTP response from a SetDeviceNameWithResponse call
|
|
func ParseSetDeviceNameResponse(rsp *http.Response) (*SetDeviceNameResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &SetDeviceNameResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest EmptyOutputBody
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON400 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseGetDeviceRoutesResponse parses an HTTP response from a GetDeviceRoutesWithResponse call
|
|
func ParseGetDeviceRoutesResponse(rsp *http.Response) (*GetDeviceRoutesResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &GetDeviceRoutesResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest DeviceRoutes
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseSetDeviceRoutesResponse parses an HTTP response from a SetDeviceRoutesWithResponse call
|
|
func ParseSetDeviceRoutesResponse(rsp *http.Response) (*SetDeviceRoutesResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &SetDeviceRoutesResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest DeviceRoutes
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON400 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseSetDeviceTagsResponse parses an HTTP response from a SetDeviceTagsWithResponse call
|
|
func ParseSetDeviceTagsResponse(rsp *http.Response) (*SetDeviceTagsResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &SetDeviceTagsResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest EmptyOutputBody
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON400 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseGetACLResponse parses an HTTP response from a GetACLWithResponse call
|
|
func ParseGetACLResponse(rsp *http.Response) (*GetACLResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &GetACLResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseSetACLResponse parses an HTTP response from a SetACLWithResponse call
|
|
func ParseSetACLResponse(rsp *http.Response) (*SetACLResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &SetACLResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON400 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 412:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON412 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseListDevicesResponse parses an HTTP response from a ListDevicesWithResponse call
|
|
func ParseListDevicesResponse(rsp *http.Response) (*ListDevicesResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &ListDevicesResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest ListDevicesOutputBody
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseListKeysResponse parses an HTTP response from a ListKeysWithResponse call
|
|
func ParseListKeysResponse(rsp *http.Response) (*ListKeysResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &ListKeysResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest ListKeysOutputBody
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseCreateKeyResponse parses an HTTP response from a CreateKeyWithResponse call
|
|
func ParseCreateKeyResponse(rsp *http.Response) (*CreateKeyResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &CreateKeyResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest Key
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON400 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseDeleteKeyResponse parses an HTTP response from a DeleteKeyWithResponse call
|
|
func ParseDeleteKeyResponse(rsp *http.Response) (*DeleteKeyResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &DeleteKeyResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest DeleteKeyOutputBody
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseGetKeyResponse parses an HTTP response from a GetKeyWithResponse call
|
|
func ParseGetKeyResponse(rsp *http.Response) (*GetKeyResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &GetKeyResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest Key
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseGetTailnetSettingsResponse parses an HTTP response from a GetTailnetSettingsWithResponse call
|
|
func ParseGetTailnetSettingsResponse(rsp *http.Response) (*GetTailnetSettingsResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &GetTailnetSettingsResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest TailnetSettings
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseUpdateTailnetSettingsResponse parses an HTTP response from a UpdateTailnetSettingsWithResponse call
|
|
func ParseUpdateTailnetSettingsResponse(rsp *http.Response) (*UpdateTailnetSettingsResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &UpdateTailnetSettingsResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest TailnetSettings
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON501 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseListUsersResponse parses an HTTP response from a ListUsersWithResponse call
|
|
func ParseListUsersResponse(rsp *http.Response) (*ListUsersResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &ListUsersResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest ListUsersOutputBody
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseGetUserResponse parses an HTTP response from a GetUserWithResponse call
|
|
func ParseGetUserResponse(rsp *http.Response) (*GetUserResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &GetUserResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest User
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON401 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON403 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON404 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON422 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
var dest ErrorModel
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.ApplicationproblemJSON500 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|