bjerkio/crayon-api-go

View on GitHub
client/clients/clients_client.go

Summary

Maintainability
D
2 days
Test Coverage
// Code generated by go-swagger; DO NOT EDIT.

package clients

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
    "fmt"

    "github.com/go-openapi/runtime"
    "github.com/go-openapi/strfmt"
)

// New creates a new clients API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
    return &Client{transport: transport, formats: formats}
}

/*
Client for clients API
*/
type Client struct {
    transport runtime.ClientTransport
    formats   strfmt.Registry
}

// ClientService is the interface for Client methods
type ClientService interface {
    CreateClients(params *CreateClientsParams, authInfo runtime.ClientAuthInfoWriter) (*CreateClientsOK, error)

    DeleteClients(params *DeleteClientsParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteClientsOK, error)

    GetClients(params *GetClientsParams, authInfo runtime.ClientAuthInfoWriter) (*GetClientsOK, error)

    UpdateClients(params *UpdateClientsParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateClientsOK, error)

    SetTransport(transport runtime.ClientTransport)
}

/*
  CreateClients create clients API
*/
func (a *Client) CreateClients(params *CreateClientsParams, authInfo runtime.ClientAuthInfoWriter) (*CreateClientsOK, error) {
    // TODO: Validate the params before sending
    if params == nil {
        params = NewCreateClientsParams()
    }

    result, err := a.transport.Submit(&runtime.ClientOperation{
        ID:                 "CreateClients",
        Method:             "POST",
        PathPattern:        "/api/v1/Clients",
        ProducesMediaTypes: []string{"application/json", "text/json", "text/plain"},
        ConsumesMediaTypes: []string{"application/*+json", "application/json", "application/json-patch+json", "text/json"},
        Schemes:            []string{"https"},
        Params:             params,
        Reader:             &CreateClientsReader{formats: a.formats},
        AuthInfo:           authInfo,
        Context:            params.Context,
        Client:             params.HTTPClient,
    })
    if err != nil {
        return nil, err
    }
    success, ok := result.(*CreateClientsOK)
    if ok {
        return success, nil
    }
    // unexpected success response
    // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    msg := fmt.Sprintf("unexpected success response for CreateClients: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    panic(msg)
}

/*
  DeleteClients delete clients API
*/
func (a *Client) DeleteClients(params *DeleteClientsParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteClientsOK, error) {
    // TODO: Validate the params before sending
    if params == nil {
        params = NewDeleteClientsParams()
    }

    result, err := a.transport.Submit(&runtime.ClientOperation{
        ID:                 "DeleteClients",
        Method:             "DELETE",
        PathPattern:        "/api/v1/Clients/{clientId}",
        ProducesMediaTypes: []string{"application/json", "text/json", "text/plain"},
        ConsumesMediaTypes: []string{"application/json"},
        Schemes:            []string{"https"},
        Params:             params,
        Reader:             &DeleteClientsReader{formats: a.formats},
        AuthInfo:           authInfo,
        Context:            params.Context,
        Client:             params.HTTPClient,
    })
    if err != nil {
        return nil, err
    }
    success, ok := result.(*DeleteClientsOK)
    if ok {
        return success, nil
    }
    // unexpected success response
    // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    msg := fmt.Sprintf("unexpected success response for DeleteClients: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    panic(msg)
}

/*
  GetClients get clients API
*/
func (a *Client) GetClients(params *GetClientsParams, authInfo runtime.ClientAuthInfoWriter) (*GetClientsOK, error) {
    // TODO: Validate the params before sending
    if params == nil {
        params = NewGetClientsParams()
    }

    result, err := a.transport.Submit(&runtime.ClientOperation{
        ID:                 "GetClients",
        Method:             "GET",
        PathPattern:        "/api/v1/Clients",
        ProducesMediaTypes: []string{"application/json", "text/json", "text/plain"},
        ConsumesMediaTypes: []string{"application/json"},
        Schemes:            []string{"https"},
        Params:             params,
        Reader:             &GetClientsReader{formats: a.formats},
        AuthInfo:           authInfo,
        Context:            params.Context,
        Client:             params.HTTPClient,
    })
    if err != nil {
        return nil, err
    }
    success, ok := result.(*GetClientsOK)
    if ok {
        return success, nil
    }
    // unexpected success response
    // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    msg := fmt.Sprintf("unexpected success response for GetClients: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    panic(msg)
}

/*
  UpdateClients update clients API
*/
func (a *Client) UpdateClients(params *UpdateClientsParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateClientsOK, error) {
    // TODO: Validate the params before sending
    if params == nil {
        params = NewUpdateClientsParams()
    }

    result, err := a.transport.Submit(&runtime.ClientOperation{
        ID:                 "UpdateClients",
        Method:             "PUT",
        PathPattern:        "/api/v1/Clients/{clientId}",
        ProducesMediaTypes: []string{"application/json", "text/json", "text/plain"},
        ConsumesMediaTypes: []string{"application/*+json", "application/json", "application/json-patch+json", "text/json"},
        Schemes:            []string{"https"},
        Params:             params,
        Reader:             &UpdateClientsReader{formats: a.formats},
        AuthInfo:           authInfo,
        Context:            params.Context,
        Client:             params.HTTPClient,
    })
    if err != nil {
        return nil, err
    }
    success, ok := result.(*UpdateClientsOK)
    if ok {
        return success, nil
    }
    // unexpected success response
    // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    msg := fmt.Sprintf("unexpected success response for UpdateClients: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    panic(msg)
}

// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
    a.transport = transport
}