github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_client/oauth/oauth_client.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package oauth
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"fmt"
    10  
    11  	"github.com/go-openapi/runtime"
    12  	"github.com/go-openapi/strfmt"
    13  )
    14  
    15  // New creates a new oauth API client.
    16  func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
    17  	return &Client{transport: transport, formats: formats}
    18  }
    19  
    20  /*
    21  Client for oauth API
    22  */
    23  type Client struct {
    24  	transport runtime.ClientTransport
    25  	formats   strfmt.Registry
    26  }
    27  
    28  // ClientOption is the option for Client methods
    29  type ClientOption func(*runtime.ClientOperation)
    30  
    31  // ClientService is the interface for Client methods
    32  type ClientService interface {
    33  	AuthDeviceGet(params *AuthDeviceGetParams, opts ...ClientOption) (*AuthDeviceGetOK, error)
    34  
    35  	AuthDevicePost(params *AuthDevicePostParams, opts ...ClientOption) (*AuthDevicePostOK, error)
    36  
    37  	AuthDevicePut(params *AuthDevicePutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AuthDevicePutOK, error)
    38  
    39  	SetTransport(transport runtime.ClientTransport)
    40  }
    41  
    42  /*
    43    AuthDeviceGet gets the status of a particular device code authorization flow based on device code
    44  */
    45  func (a *Client) AuthDeviceGet(params *AuthDeviceGetParams, opts ...ClientOption) (*AuthDeviceGetOK, error) {
    46  	// TODO: Validate the params before sending
    47  	if params == nil {
    48  		params = NewAuthDeviceGetParams()
    49  	}
    50  	op := &runtime.ClientOperation{
    51  		ID:                 "authDeviceGet",
    52  		Method:             "GET",
    53  		PathPattern:        "/oauth/authorize/device",
    54  		ProducesMediaTypes: []string{"application/json"},
    55  		ConsumesMediaTypes: []string{"application/json"},
    56  		Schemes:            []string{"http", "https"},
    57  		Params:             params,
    58  		Reader:             &AuthDeviceGetReader{formats: a.formats},
    59  		Context:            params.Context,
    60  		Client:             params.HTTPClient,
    61  	}
    62  	for _, opt := range opts {
    63  		opt(op)
    64  	}
    65  
    66  	result, err := a.transport.Submit(op)
    67  	if err != nil {
    68  		return nil, err
    69  	}
    70  	success, ok := result.(*AuthDeviceGetOK)
    71  	if ok {
    72  		return success, nil
    73  	}
    74  	// unexpected success response
    75  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    76  	msg := fmt.Sprintf("unexpected success response for authDeviceGet: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    77  	panic(msg)
    78  }
    79  
    80  /*
    81    AuthDevicePost initializes device o a u t h flow with the API
    82  */
    83  func (a *Client) AuthDevicePost(params *AuthDevicePostParams, opts ...ClientOption) (*AuthDevicePostOK, error) {
    84  	// TODO: Validate the params before sending
    85  	if params == nil {
    86  		params = NewAuthDevicePostParams()
    87  	}
    88  	op := &runtime.ClientOperation{
    89  		ID:                 "authDevicePost",
    90  		Method:             "POST",
    91  		PathPattern:        "/oauth/authorize/device",
    92  		ProducesMediaTypes: []string{"application/json"},
    93  		ConsumesMediaTypes: []string{"application/json"},
    94  		Schemes:            []string{"http", "https"},
    95  		Params:             params,
    96  		Reader:             &AuthDevicePostReader{formats: a.formats},
    97  		Context:            params.Context,
    98  		Client:             params.HTTPClient,
    99  	}
   100  	for _, opt := range opts {
   101  		opt(op)
   102  	}
   103  
   104  	result, err := a.transport.Submit(op)
   105  	if err != nil {
   106  		return nil, err
   107  	}
   108  	success, ok := result.(*AuthDevicePostOK)
   109  	if ok {
   110  		return success, nil
   111  	}
   112  	// unexpected success response
   113  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   114  	msg := fmt.Sprintf("unexpected success response for authDevicePost: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   115  	panic(msg)
   116  }
   117  
   118  /*
   119    AuthDevicePut authorizes user code this endpoint completes the device authorization grant flow successfully
   120  */
   121  func (a *Client) AuthDevicePut(params *AuthDevicePutParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AuthDevicePutOK, error) {
   122  	// TODO: Validate the params before sending
   123  	if params == nil {
   124  		params = NewAuthDevicePutParams()
   125  	}
   126  	op := &runtime.ClientOperation{
   127  		ID:                 "authDevicePut",
   128  		Method:             "PUT",
   129  		PathPattern:        "/oauth/authorize/device",
   130  		ProducesMediaTypes: []string{"application/json"},
   131  		ConsumesMediaTypes: []string{"application/json"},
   132  		Schemes:            []string{"http", "https"},
   133  		Params:             params,
   134  		Reader:             &AuthDevicePutReader{formats: a.formats},
   135  		AuthInfo:           authInfo,
   136  		Context:            params.Context,
   137  		Client:             params.HTTPClient,
   138  	}
   139  	for _, opt := range opts {
   140  		opt(op)
   141  	}
   142  
   143  	result, err := a.transport.Submit(op)
   144  	if err != nil {
   145  		return nil, err
   146  	}
   147  	success, ok := result.(*AuthDevicePutOK)
   148  	if ok {
   149  		return success, nil
   150  	}
   151  	// unexpected success response
   152  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   153  	msg := fmt.Sprintf("unexpected success response for authDevicePut: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   154  	panic(msg)
   155  }
   156  
   157  // SetTransport changes the transport on the client
   158  func (a *Client) SetTransport(transport runtime.ClientTransport) {
   159  	a.transport = transport
   160  }