diff --git a/api/docs.go b/api/docs.go index 832bdecba54cc4ff3647cca289f065f13022dcc5..9bef7b3cfe81a6d4a8095ddd26457b676e43534c 100644 --- a/api/docs.go +++ b/api/docs.go @@ -59,6 +59,12 @@ const docTemplate = `{ "$ref": "#/definitions/models.Bridge" } }, + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/models.Bridge" + } + }, "400": { "description": "Bad Request", "schema": {} @@ -110,6 +116,12 @@ const docTemplate = `{ "$ref": "#/definitions/models.Gateway" } }, + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/models.Gateway" + } + }, "400": { "description": "Bad Request", "schema": {} diff --git a/api/swagger.json b/api/swagger.json index 592309c002312554890208484ae3dcfc97233510..385be1efb748f140eff5d68fd83690dc6970bfd3 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -53,6 +53,12 @@ "$ref": "#/definitions/models.Bridge" } }, + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/models.Bridge" + } + }, "400": { "description": "Bad Request", "schema": {} @@ -104,6 +110,12 @@ "$ref": "#/definitions/models.Gateway" } }, + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/models.Gateway" + } + }, "400": { "description": "Bad Request", "schema": {} diff --git a/api/swagger.yaml b/api/swagger.yaml index 875b79a8936fbd17ed75359f6ad4e22d2ebbc69d..a7d46624d574edb570149bdb1d87cbb338649635 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -315,6 +315,10 @@ paths: description: OK schema: $ref: '#/definitions/models.Bridge' + "201": + description: Created + schema: + $ref: '#/definitions/models.Bridge' "400": description: Bad Request schema: {} @@ -349,6 +353,10 @@ paths: description: OK schema: $ref: '#/definitions/models.Gateway' + "201": + description: Created + schema: + $ref: '#/definitions/models.Gateway' "400": description: Bad Request schema: {} diff --git a/client/agent/agent_client.go b/client/agent/agent_client.go index 8268a0066de7576d1b08c84c3d33f59ab2ef5bce..238b4f9803b84f2c843c21d7228c114ad010bdd6 100644 --- a/client/agent/agent_client.go +++ b/client/agent/agent_client.go @@ -56,9 +56,9 @@ type ClientOption func(*runtime.ClientOperation) // ClientService is the interface for Client methods type ClientService interface { - PutAPI5AgentBridge(params *PutAPI5AgentBridgeParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutApi5AgentBridgeOK, error) + PutAPI5AgentBridge(params *PutAPI5AgentBridgeParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutApi5AgentBridgeOK, *PutApi5AgentBridgeCreated, error) - PutAPI5AgentGateway(params *PutAPI5AgentGatewayParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutApi5AgentGatewayOK, error) + PutAPI5AgentGateway(params *PutAPI5AgentGatewayParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutApi5AgentGatewayOK, *PutApi5AgentGatewayCreated, error) SetTransport(transport runtime.ClientTransport) } @@ -68,7 +68,7 @@ PutAPI5AgentBridge registers a bridge Register a bridge. This endpoint allows "menshen agent" processes running on bridges to register themselves. */ -func (a *Client) PutAPI5AgentBridge(params *PutAPI5AgentBridgeParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutApi5AgentBridgeOK, error) { +func (a *Client) PutAPI5AgentBridge(params *PutAPI5AgentBridgeParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutApi5AgentBridgeOK, *PutApi5AgentBridgeCreated, error) { // TODO: Validate the params before sending if params == nil { params = NewPutAPI5AgentBridgeParams() @@ -92,15 +92,16 @@ func (a *Client) PutAPI5AgentBridge(params *PutAPI5AgentBridgeParams, authInfo r result, err := a.transport.Submit(op) if err != nil { - return nil, err + return nil, nil, err } - success, ok := result.(*PutApi5AgentBridgeOK) - if ok { - return success, nil + switch value := result.(type) { + case *PutApi5AgentBridgeOK: + return value, nil, nil + case *PutApi5AgentBridgeCreated: + return nil, value, 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 PutAPI5AgentBridge: API contract not enforced by server. Client expected to get an error, but got: %T", result) + msg := fmt.Sprintf("unexpected success response for agent: API contract not enforced by server. Client expected to get an error, but got: %T", result) panic(msg) } @@ -109,7 +110,7 @@ PutAPI5AgentGateway registers a gateway Register a gateway. This endpoint allows "menshen agent" processes running on gateways to register themselves. */ -func (a *Client) PutAPI5AgentGateway(params *PutAPI5AgentGatewayParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutApi5AgentGatewayOK, error) { +func (a *Client) PutAPI5AgentGateway(params *PutAPI5AgentGatewayParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutApi5AgentGatewayOK, *PutApi5AgentGatewayCreated, error) { // TODO: Validate the params before sending if params == nil { params = NewPutAPI5AgentGatewayParams() @@ -133,15 +134,16 @@ func (a *Client) PutAPI5AgentGateway(params *PutAPI5AgentGatewayParams, authInfo result, err := a.transport.Submit(op) if err != nil { - return nil, err + return nil, nil, err } - success, ok := result.(*PutApi5AgentGatewayOK) - if ok { - return success, nil + switch value := result.(type) { + case *PutApi5AgentGatewayOK: + return value, nil, nil + case *PutApi5AgentGatewayCreated: + return nil, value, 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 PutAPI5AgentGateway: API contract not enforced by server. Client expected to get an error, but got: %T", result) + msg := fmt.Sprintf("unexpected success response for agent: API contract not enforced by server. Client expected to get an error, but got: %T", result) panic(msg) } diff --git a/client/agent/put_api_5_agent_bridge_responses.go b/client/agent/put_api_5_agent_bridge_responses.go index 9f9489f6537784566311703d439d784094ca55a6..9f798ca835610e8e4ed627242959627930083404 100644 --- a/client/agent/put_api_5_agent_bridge_responses.go +++ b/client/agent/put_api_5_agent_bridge_responses.go @@ -30,6 +30,12 @@ func (o *PutAPI5AgentBridgeReader) ReadResponse(response runtime.ClientResponse, return nil, err } return result, nil + case 201: + result := NewPutApi5AgentBridgeCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil case 400: result := NewPutApi5AgentBridgeBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -123,6 +129,76 @@ func (o *PutApi5AgentBridgeOK) readResponse(response runtime.ClientResponse, con return nil } +// NewPutApi5AgentBridgeCreated creates a PutApi5AgentBridgeCreated with default headers values +func NewPutApi5AgentBridgeCreated() *PutApi5AgentBridgeCreated { + return &PutApi5AgentBridgeCreated{} +} + +/* +PutApi5AgentBridgeCreated describes a response with status code 201, with default header values. + +Created +*/ +type PutApi5AgentBridgeCreated struct { + Payload *models.ModelsBridge +} + +// IsSuccess returns true when this put api5 agent bridge created response has a 2xx status code +func (o *PutApi5AgentBridgeCreated) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put api5 agent bridge created response has a 3xx status code +func (o *PutApi5AgentBridgeCreated) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put api5 agent bridge created response has a 4xx status code +func (o *PutApi5AgentBridgeCreated) IsClientError() bool { + return false +} + +// IsServerError returns true when this put api5 agent bridge created response has a 5xx status code +func (o *PutApi5AgentBridgeCreated) IsServerError() bool { + return false +} + +// IsCode returns true when this put api5 agent bridge created response a status code equal to that given +func (o *PutApi5AgentBridgeCreated) IsCode(code int) bool { + return code == 201 +} + +// Code gets the status code for the put api5 agent bridge created response +func (o *PutApi5AgentBridgeCreated) Code() int { + return 201 +} + +func (o *PutApi5AgentBridgeCreated) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /api/5/agent/bridge][%d] putApi5AgentBridgeCreated %s", 201, payload) +} + +func (o *PutApi5AgentBridgeCreated) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /api/5/agent/bridge][%d] putApi5AgentBridgeCreated %s", 201, payload) +} + +func (o *PutApi5AgentBridgeCreated) GetPayload() *models.ModelsBridge { + return o.Payload +} + +func (o *PutApi5AgentBridgeCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ModelsBridge) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + // NewPutApi5AgentBridgeBadRequest creates a PutApi5AgentBridgeBadRequest with default headers values func NewPutApi5AgentBridgeBadRequest() *PutApi5AgentBridgeBadRequest { return &PutApi5AgentBridgeBadRequest{} diff --git a/client/agent/put_api_5_agent_gateway_responses.go b/client/agent/put_api_5_agent_gateway_responses.go index 6a1dbbff208cfeaa3939b532cf406af367bb26c1..bcc21ac52837ac9eb5978b526a9dcb395e95edfa 100644 --- a/client/agent/put_api_5_agent_gateway_responses.go +++ b/client/agent/put_api_5_agent_gateway_responses.go @@ -30,6 +30,12 @@ func (o *PutAPI5AgentGatewayReader) ReadResponse(response runtime.ClientResponse return nil, err } return result, nil + case 201: + result := NewPutApi5AgentGatewayCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil case 400: result := NewPutApi5AgentGatewayBadRequest() if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -123,6 +129,76 @@ func (o *PutApi5AgentGatewayOK) readResponse(response runtime.ClientResponse, co return nil } +// NewPutApi5AgentGatewayCreated creates a PutApi5AgentGatewayCreated with default headers values +func NewPutApi5AgentGatewayCreated() *PutApi5AgentGatewayCreated { + return &PutApi5AgentGatewayCreated{} +} + +/* +PutApi5AgentGatewayCreated describes a response with status code 201, with default header values. + +Created +*/ +type PutApi5AgentGatewayCreated struct { + Payload *models.ModelsGateway +} + +// IsSuccess returns true when this put api5 agent gateway created response has a 2xx status code +func (o *PutApi5AgentGatewayCreated) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put api5 agent gateway created response has a 3xx status code +func (o *PutApi5AgentGatewayCreated) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put api5 agent gateway created response has a 4xx status code +func (o *PutApi5AgentGatewayCreated) IsClientError() bool { + return false +} + +// IsServerError returns true when this put api5 agent gateway created response has a 5xx status code +func (o *PutApi5AgentGatewayCreated) IsServerError() bool { + return false +} + +// IsCode returns true when this put api5 agent gateway created response a status code equal to that given +func (o *PutApi5AgentGatewayCreated) IsCode(code int) bool { + return code == 201 +} + +// Code gets the status code for the put api5 agent gateway created response +func (o *PutApi5AgentGatewayCreated) Code() int { + return 201 +} + +func (o *PutApi5AgentGatewayCreated) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /api/5/agent/gateway][%d] putApi5AgentGatewayCreated %s", 201, payload) +} + +func (o *PutApi5AgentGatewayCreated) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /api/5/agent/gateway][%d] putApi5AgentGatewayCreated %s", 201, payload) +} + +func (o *PutApi5AgentGatewayCreated) GetPayload() *models.ModelsGateway { + return o.Payload +} + +func (o *PutApi5AgentGatewayCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ModelsGateway) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + // NewPutApi5AgentGatewayBadRequest creates a PutApi5AgentGatewayBadRequest with default headers values func NewPutApi5AgentGatewayBadRequest() *PutApi5AgentGatewayBadRequest { return &PutApi5AgentGatewayBadRequest{}