github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/clients/client_id/client__generated.go (about)

     1  package client_id
     2  
     3  import (
     4  	"fmt"
     5  
     6  	github_com_johnnyeven_libtools_courier "github.com/johnnyeven/libtools/courier"
     7  	github_com_johnnyeven_libtools_courier_client "github.com/johnnyeven/libtools/courier/client"
     8  	github_com_johnnyeven_libtools_courier_status_error "github.com/johnnyeven/libtools/courier/status_error"
     9  )
    10  
    11  type ClientIDInterface interface {
    12  	GetNewId(metas ...github_com_johnnyeven_libtools_courier.Metadata) (resp *GetNewIdResponse, err error)
    13  }
    14  
    15  type ClientID struct {
    16  	github_com_johnnyeven_libtools_courier_client.Client
    17  }
    18  
    19  func (ClientID) MarshalDefaults(v interface{}) {
    20  	if cl, ok := v.(*ClientID); ok {
    21  		cl.Name = "id"
    22  		cl.Client.MarshalDefaults(&cl.Client)
    23  	}
    24  }
    25  
    26  func (c ClientID) Init() {
    27  	c.CheckService()
    28  }
    29  
    30  func (c ClientID) CheckService() {
    31  	err := c.Request(c.Name+".Check", "HEAD", "/", nil).
    32  		Do().
    33  		Into(nil)
    34  	statusErr := github_com_johnnyeven_libtools_courier_status_error.FromError(err)
    35  	if statusErr.Code == int64(github_com_johnnyeven_libtools_courier_status_error.RequestTimeout) {
    36  		panic(fmt.Errorf("service %s have some error %s", c.Name, statusErr))
    37  	}
    38  }
    39  
    40  func (c ClientID) GetNewId(metas ...github_com_johnnyeven_libtools_courier.Metadata) (resp *GetNewIdResponse, err error) {
    41  	resp = &GetNewIdResponse{}
    42  	resp.Meta = github_com_johnnyeven_libtools_courier.Metadata{}
    43  
    44  	err = c.Request(c.Name+".GetNewId", "GET", "/id/v0/id", nil, metas...).
    45  		Do().
    46  		BindMeta(resp.Meta).
    47  		Into(&resp.Body)
    48  
    49  	return
    50  }
    51  
    52  type GetNewIdResponse struct {
    53  	Meta github_com_johnnyeven_libtools_courier.Metadata
    54  	Body UniqueID
    55  }
    56  
    57  func (c ClientID) Swagger(metas ...github_com_johnnyeven_libtools_courier.Metadata) (resp *SwaggerResponse, err error) {
    58  	resp = &SwaggerResponse{}
    59  	resp.Meta = github_com_johnnyeven_libtools_courier.Metadata{}
    60  
    61  	err = c.Request(c.Name+".Swagger", "GET", "/id", nil, metas...).
    62  		Do().
    63  		BindMeta(resp.Meta).
    64  		Into(&resp.Body)
    65  
    66  	return
    67  }
    68  
    69  type SwaggerResponse struct {
    70  	Meta github_com_johnnyeven_libtools_courier.Metadata
    71  	Body JSONBytes
    72  }