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