github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/examples/contributed-templates/stratoscale/client/pet/pet_client.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package pet
     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  	"context"
    10  
    11  	"github.com/go-openapi/runtime"
    12  
    13  	strfmt "github.com/go-openapi/strfmt"
    14  )
    15  
    16  //go:generate mockery -name API -inpkg
    17  
    18  // API is the interface of the pet client
    19  type API interface {
    20  	/*
    21  	   PetCreate adds a new pet to the store*/
    22  	PetCreate(ctx context.Context, params *PetCreateParams) (*PetCreateCreated, error)
    23  	/*
    24  	   PetDelete deletes a pet*/
    25  	PetDelete(ctx context.Context, params *PetDeleteParams) (*PetDeleteNoContent, error)
    26  	/*
    27  	   PetGet gets pet by it s ID*/
    28  	PetGet(ctx context.Context, params *PetGetParams) (*PetGetOK, error)
    29  	/*
    30  	   PetList lists pets*/
    31  	PetList(ctx context.Context, params *PetListParams) (*PetListOK, error)
    32  	/*
    33  	   PetUpdate updates an existing pet*/
    34  	PetUpdate(ctx context.Context, params *PetUpdateParams) (*PetUpdateCreated, error)
    35  	/*
    36  	   PetUploadImage uploads an image*/
    37  	PetUploadImage(ctx context.Context, params *PetUploadImageParams) (*PetUploadImageOK, error)
    38  }
    39  
    40  // New creates a new pet API client.
    41  func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client {
    42  	return &Client{
    43  		transport: transport,
    44  		formats:   formats,
    45  		authInfo:  authInfo,
    46  	}
    47  }
    48  
    49  /*
    50  Client for pet API
    51  */
    52  type Client struct {
    53  	transport runtime.ClientTransport
    54  	formats   strfmt.Registry
    55  	authInfo  runtime.ClientAuthInfoWriter
    56  }
    57  
    58  /*
    59  PetCreate adds a new pet to the store
    60  */
    61  func (a *Client) PetCreate(ctx context.Context, params *PetCreateParams) (*PetCreateCreated, error) {
    62  
    63  	result, err := a.transport.Submit(&runtime.ClientOperation{
    64  		ID:                 "PetCreate",
    65  		Method:             "POST",
    66  		PathPattern:        "/pet",
    67  		ProducesMediaTypes: []string{"application/json"},
    68  		ConsumesMediaTypes: []string{"application/json"},
    69  		Schemes:            []string{"http"},
    70  		Params:             params,
    71  		Reader:             &PetCreateReader{formats: a.formats},
    72  		AuthInfo:           a.authInfo,
    73  		Context:            ctx,
    74  		Client:             params.HTTPClient,
    75  	})
    76  	if err != nil {
    77  		return nil, err
    78  	}
    79  	return result.(*PetCreateCreated), nil
    80  
    81  }
    82  
    83  /*
    84  PetDelete deletes a pet
    85  */
    86  func (a *Client) PetDelete(ctx context.Context, params *PetDeleteParams) (*PetDeleteNoContent, error) {
    87  
    88  	result, err := a.transport.Submit(&runtime.ClientOperation{
    89  		ID:                 "PetDelete",
    90  		Method:             "DELETE",
    91  		PathPattern:        "/pet/{petId}",
    92  		ProducesMediaTypes: []string{"application/json"},
    93  		ConsumesMediaTypes: []string{"application/json"},
    94  		Schemes:            []string{"http"},
    95  		Params:             params,
    96  		Reader:             &PetDeleteReader{formats: a.formats},
    97  		AuthInfo:           a.authInfo,
    98  		Context:            ctx,
    99  		Client:             params.HTTPClient,
   100  	})
   101  	if err != nil {
   102  		return nil, err
   103  	}
   104  	return result.(*PetDeleteNoContent), nil
   105  
   106  }
   107  
   108  /*
   109  PetGet gets pet by it s ID
   110  */
   111  func (a *Client) PetGet(ctx context.Context, params *PetGetParams) (*PetGetOK, error) {
   112  
   113  	result, err := a.transport.Submit(&runtime.ClientOperation{
   114  		ID:                 "PetGet",
   115  		Method:             "GET",
   116  		PathPattern:        "/pet/{petId}",
   117  		ProducesMediaTypes: []string{"application/json"},
   118  		ConsumesMediaTypes: []string{"application/json"},
   119  		Schemes:            []string{"http"},
   120  		Params:             params,
   121  		Reader:             &PetGetReader{formats: a.formats},
   122  		AuthInfo:           a.authInfo,
   123  		Context:            ctx,
   124  		Client:             params.HTTPClient,
   125  	})
   126  	if err != nil {
   127  		return nil, err
   128  	}
   129  	return result.(*PetGetOK), nil
   130  
   131  }
   132  
   133  /*
   134  PetList lists pets
   135  */
   136  func (a *Client) PetList(ctx context.Context, params *PetListParams) (*PetListOK, error) {
   137  
   138  	result, err := a.transport.Submit(&runtime.ClientOperation{
   139  		ID:                 "PetList",
   140  		Method:             "GET",
   141  		PathPattern:        "/pet",
   142  		ProducesMediaTypes: []string{"application/json"},
   143  		ConsumesMediaTypes: []string{"application/json"},
   144  		Schemes:            []string{"http"},
   145  		Params:             params,
   146  		Reader:             &PetListReader{formats: a.formats},
   147  		AuthInfo:           a.authInfo,
   148  		Context:            ctx,
   149  		Client:             params.HTTPClient,
   150  	})
   151  	if err != nil {
   152  		return nil, err
   153  	}
   154  	return result.(*PetListOK), nil
   155  
   156  }
   157  
   158  /*
   159  PetUpdate updates an existing pet
   160  */
   161  func (a *Client) PetUpdate(ctx context.Context, params *PetUpdateParams) (*PetUpdateCreated, error) {
   162  
   163  	result, err := a.transport.Submit(&runtime.ClientOperation{
   164  		ID:                 "PetUpdate",
   165  		Method:             "PUT",
   166  		PathPattern:        "/pet",
   167  		ProducesMediaTypes: []string{"application/json"},
   168  		ConsumesMediaTypes: []string{"application/json"},
   169  		Schemes:            []string{"http"},
   170  		Params:             params,
   171  		Reader:             &PetUpdateReader{formats: a.formats},
   172  		AuthInfo:           a.authInfo,
   173  		Context:            ctx,
   174  		Client:             params.HTTPClient,
   175  	})
   176  	if err != nil {
   177  		return nil, err
   178  	}
   179  	return result.(*PetUpdateCreated), nil
   180  
   181  }
   182  
   183  /*
   184  PetUploadImage uploads an image
   185  */
   186  func (a *Client) PetUploadImage(ctx context.Context, params *PetUploadImageParams) (*PetUploadImageOK, error) {
   187  
   188  	result, err := a.transport.Submit(&runtime.ClientOperation{
   189  		ID:                 "PetUploadImage",
   190  		Method:             "POST",
   191  		PathPattern:        "/pet/{petId}/image",
   192  		ProducesMediaTypes: []string{"application/json"},
   193  		ConsumesMediaTypes: []string{"application/json"},
   194  		Schemes:            []string{"http"},
   195  		Params:             params,
   196  		Reader:             &PetUploadImageReader{formats: a.formats},
   197  		AuthInfo:           a.authInfo,
   198  		Context:            ctx,
   199  		Client:             params.HTTPClient,
   200  	})
   201  	if err != nil {
   202  		return nil, err
   203  	}
   204  	return result.(*PetUploadImageOK), nil
   205  
   206  }