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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package status
     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 status 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 status 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  	GetInfo(params *GetInfoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInfoOK, error)
    34  
    35  	Usage(params *UsageParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UsageOK, error)
    36  
    37  	SetTransport(transport runtime.ClientTransport)
    38  }
    39  
    40  /*
    41    GetInfo tests method for developer testing
    42  
    43    Helpful for testing JWT operation
    44  */
    45  func (a *Client) GetInfo(params *GetInfoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInfoOK, error) {
    46  	// TODO: Validate the params before sending
    47  	if params == nil {
    48  		params = NewGetInfoParams()
    49  	}
    50  	op := &runtime.ClientOperation{
    51  		ID:                 "GetInfo",
    52  		Method:             "GET",
    53  		PathPattern:        "/info",
    54  		ProducesMediaTypes: []string{"application/json"},
    55  		ConsumesMediaTypes: []string{"application/json"},
    56  		Schemes:            []string{"http", "https"},
    57  		Params:             params,
    58  		Reader:             &GetInfoReader{formats: a.formats},
    59  		AuthInfo:           authInfo,
    60  		Context:            params.Context,
    61  		Client:             params.HTTPClient,
    62  	}
    63  	for _, opt := range opts {
    64  		opt(op)
    65  	}
    66  
    67  	result, err := a.transport.Submit(op)
    68  	if err != nil {
    69  		return nil, err
    70  	}
    71  	success, ok := result.(*GetInfoOK)
    72  	if ok {
    73  		return success, nil
    74  	}
    75  	// unexpected success response
    76  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    77  	msg := fmt.Sprintf("unexpected success response for GetInfo: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    78  	panic(msg)
    79  }
    80  
    81  /*
    82    Usage reports platform usage statistics
    83  
    84    Active users by date range
    85  */
    86  func (a *Client) Usage(params *UsageParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UsageOK, error) {
    87  	// TODO: Validate the params before sending
    88  	if params == nil {
    89  		params = NewUsageParams()
    90  	}
    91  	op := &runtime.ClientOperation{
    92  		ID:                 "usage",
    93  		Method:             "GET",
    94  		PathPattern:        "/usage",
    95  		ProducesMediaTypes: []string{"application/json"},
    96  		ConsumesMediaTypes: []string{"application/json"},
    97  		Schemes:            []string{"http", "https"},
    98  		Params:             params,
    99  		Reader:             &UsageReader{formats: a.formats},
   100  		AuthInfo:           authInfo,
   101  		Context:            params.Context,
   102  		Client:             params.HTTPClient,
   103  	}
   104  	for _, opt := range opts {
   105  		opt(op)
   106  	}
   107  
   108  	result, err := a.transport.Submit(op)
   109  	if err != nil {
   110  		return nil, err
   111  	}
   112  	success, ok := result.(*UsageOK)
   113  	if ok {
   114  		return success, nil
   115  	}
   116  	// unexpected success response
   117  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   118  	msg := fmt.Sprintf("unexpected success response for usage: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   119  	panic(msg)
   120  }
   121  
   122  // SetTransport changes the transport on the client
   123  func (a *Client) SetTransport(transport runtime.ClientTransport) {
   124  	a.transport = transport
   125  }