github.com/cilium/cilium@v1.16.2/api/v1/client/ipam/ipam_client.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright Authors of Cilium 4 // SPDX-License-Identifier: Apache-2.0 5 6 package ipam 7 8 // This file was generated by the swagger tool. 9 // Editing this file might prove futile when you re-run the swagger generate command 10 11 import ( 12 "fmt" 13 14 "github.com/go-openapi/runtime" 15 "github.com/go-openapi/strfmt" 16 ) 17 18 // New creates a new ipam API client. 19 func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { 20 return &Client{transport: transport, formats: formats} 21 } 22 23 /* 24 Client for ipam API 25 */ 26 type Client struct { 27 transport runtime.ClientTransport 28 formats strfmt.Registry 29 } 30 31 // ClientOption is the option for Client methods 32 type ClientOption func(*runtime.ClientOperation) 33 34 // ClientService is the interface for Client methods 35 type ClientService interface { 36 DeleteIpamIP(params *DeleteIpamIPParams, opts ...ClientOption) (*DeleteIpamIPOK, error) 37 38 PostIpam(params *PostIpamParams, opts ...ClientOption) (*PostIpamCreated, error) 39 40 PostIpamIP(params *PostIpamIPParams, opts ...ClientOption) (*PostIpamIPOK, error) 41 42 SetTransport(transport runtime.ClientTransport) 43 } 44 45 /* 46 DeleteIpamIP releases an allocated IP address 47 */ 48 func (a *Client) DeleteIpamIP(params *DeleteIpamIPParams, opts ...ClientOption) (*DeleteIpamIPOK, error) { 49 // TODO: Validate the params before sending 50 if params == nil { 51 params = NewDeleteIpamIPParams() 52 } 53 op := &runtime.ClientOperation{ 54 ID: "DeleteIpamIP", 55 Method: "DELETE", 56 PathPattern: "/ipam/{ip}", 57 ProducesMediaTypes: []string{"application/json"}, 58 ConsumesMediaTypes: []string{"application/json"}, 59 Schemes: []string{"http"}, 60 Params: params, 61 Reader: &DeleteIpamIPReader{formats: a.formats}, 62 Context: params.Context, 63 Client: params.HTTPClient, 64 } 65 for _, opt := range opts { 66 opt(op) 67 } 68 69 result, err := a.transport.Submit(op) 70 if err != nil { 71 return nil, err 72 } 73 success, ok := result.(*DeleteIpamIPOK) 74 if ok { 75 return success, nil 76 } 77 // unexpected success response 78 // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue 79 msg := fmt.Sprintf("unexpected success response for DeleteIpamIP: API contract not enforced by server. Client expected to get an error, but got: %T", result) 80 panic(msg) 81 } 82 83 /* 84 PostIpam allocates an IP address 85 */ 86 func (a *Client) PostIpam(params *PostIpamParams, opts ...ClientOption) (*PostIpamCreated, error) { 87 // TODO: Validate the params before sending 88 if params == nil { 89 params = NewPostIpamParams() 90 } 91 op := &runtime.ClientOperation{ 92 ID: "PostIpam", 93 Method: "POST", 94 PathPattern: "/ipam", 95 ProducesMediaTypes: []string{"application/json"}, 96 ConsumesMediaTypes: []string{"application/json"}, 97 Schemes: []string{"http"}, 98 Params: params, 99 Reader: &PostIpamReader{formats: a.formats}, 100 Context: params.Context, 101 Client: params.HTTPClient, 102 } 103 for _, opt := range opts { 104 opt(op) 105 } 106 107 result, err := a.transport.Submit(op) 108 if err != nil { 109 return nil, err 110 } 111 success, ok := result.(*PostIpamCreated) 112 if ok { 113 return success, nil 114 } 115 // unexpected success response 116 // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue 117 msg := fmt.Sprintf("unexpected success response for PostIpam: API contract not enforced by server. Client expected to get an error, but got: %T", result) 118 panic(msg) 119 } 120 121 /* 122 PostIpamIP allocates an IP address 123 */ 124 func (a *Client) PostIpamIP(params *PostIpamIPParams, opts ...ClientOption) (*PostIpamIPOK, error) { 125 // TODO: Validate the params before sending 126 if params == nil { 127 params = NewPostIpamIPParams() 128 } 129 op := &runtime.ClientOperation{ 130 ID: "PostIpamIP", 131 Method: "POST", 132 PathPattern: "/ipam/{ip}", 133 ProducesMediaTypes: []string{"application/json"}, 134 ConsumesMediaTypes: []string{"application/json"}, 135 Schemes: []string{"http"}, 136 Params: params, 137 Reader: &PostIpamIPReader{formats: a.formats}, 138 Context: params.Context, 139 Client: params.HTTPClient, 140 } 141 for _, opt := range opts { 142 opt(op) 143 } 144 145 result, err := a.transport.Submit(op) 146 if err != nil { 147 return nil, err 148 } 149 success, ok := result.(*PostIpamIPOK) 150 if ok { 151 return success, nil 152 } 153 // unexpected success response 154 // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue 155 msg := fmt.Sprintf("unexpected success response for PostIpamIP: API contract not enforced by server. Client expected to get an error, but got: %T", result) 156 panic(msg) 157 } 158 159 // SetTransport changes the transport on the client 160 func (a *Client) SetTransport(transport runtime.ClientTransport) { 161 a.transport = transport 162 }