Documentation ¶
Index ¶
- Constants
- type AcceptedAsyncResponse
- type AsyncOperationResponse
- type AsyncOperationResultResponse
- type BadRequestResponse
- type ClientAuthenticationFailed
- type ConflictResponse
- type CreatedAsyncResponse
- type CreatedResponse
- type InternalServerErrorResponse
- type MethodNotAllowedResponse
- type NoContentResponse
- type NotFoundResponse
- type OKResponse
- type PreconditionFailedResponse
- type Response
- func NewAcceptedAsyncResponse(body any, location string, scheme string) Response
- func NewAsyncOperationResultResponse(headers map[string]string) Response
- func NewBadRequestARMResponse(body v1.ErrorResponse) Response
- func NewBadRequestResponse(message string) Response
- func NewClientAuthenticationFailedARMResponse() Response
- func NewConflictResponse(message string) Response
- func NewCreatedAsyncResponse(body any, location string, scheme string) Response
- func NewCreatedResponse(body any) Response
- func NewDependencyMissingResponse(message string) Response
- func NewInternalServerErrorARMResponse(body v1.ErrorResponse) Response
- func NewLinkedResourceUpdateErrorResponse(resourceID resources.ID, oldProp *rpv1.BasicResourceProperties, ...) Response
- func NewMethodNotAllowedResponse(target string, message string) Response
- func NewNoContentResponse() Response
- func NewNotFoundAPIVersionResponse(resourceType string, namespace string, apiVersion string) Response
- func NewNotFoundMessageResponse(message string) Response
- func NewNotFoundResponse(id resources.ID) Response
- func NewOKResponse(body any) Response
- func NewOKResponseWithHeaders(body any, headers map[string]string) Response
- func NewPreconditionFailedResponse(target string, message string) Response
- func NewValidationErrorResponse(errors validator.ValidationErrors) Response
- type ValidationErrorResponse
Constants ¶
const (
LinkedResourceUpdateErrorFormat = "" /* 285-byte string literal not displayed */
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcceptedAsyncResponse ¶
AcceptedAsyncResponse represents an HTTP 202 with a JSON payload and location header.
This is used when a request to create an existing resource is processed asynchronously.
func (*AcceptedAsyncResponse) Apply ¶
func (r *AcceptedAsyncResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply renders Accepted HTTP Response into http.ResponseWriter with Location header for asynchronous operation and returns an error if it fails.
type AsyncOperationResponse ¶
type AsyncOperationResponse struct { Body any Location string Code int ResourceID resources.ID OperationID uuid.UUID APIVersion string RootScope string // Everything before providers namespace for constructing an Async operation header. Used for AWS planes PathBase string // Base Path. Used for AWS planes // RetryAfter is the value of the Retry-After header in seconds (as a string). This determines the client's polling interval. // Defaults to v1.DefaultRetryAfter. Consider setting a smaller value if your operation is expected to complete quickly. RetryAfter time.Duration }
AsyncOperationResponse represents the response for an async operation request.
func NewAsyncOperationResponse ¶
func NewAsyncOperationResponse(body any, location string, code int, resourceID resources.ID, operationID uuid.UUID, apiVersion string, rootScope string, pathBase string) *AsyncOperationResponse
NewAsyncOperationResponse creates an AsyncOperationResponse
func (*AsyncOperationResponse) Apply ¶
func (r *AsyncOperationResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply renders asynchronous operationStatuses response with Location/Azure-AsyncOperation URL headers and Retry-After header, which allows client to retry.
type AsyncOperationResultResponse ¶
AsyncOperationResultResponse
func (*AsyncOperationResultResponse) Apply ¶
func (r *AsyncOperationResultResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply sets the response headers and status code to http.StatusAccepted and returns nil.
type BadRequestResponse ¶
type BadRequestResponse struct {
Body v1.ErrorResponse
}
BadRequestResponse represents an HTTP 400 with an error message in ARM error format.
This is used for any operation that fails due to bad data with a simple error message.
func (*BadRequestResponse) Apply ¶
func (r *BadRequestResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply renders the general BadRequest HTTP response into http.ResponseWriter by serializing ErrorResponse.
type ClientAuthenticationFailed ¶
type ClientAuthenticationFailed struct {
Body v1.ErrorResponse
}
ClientAuthenticationFailed represents an HTTP 401 with an ARM error payload.
func (*ClientAuthenticationFailed) Apply ¶
func (r *ClientAuthenticationFailed) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply writes a response with status code 401 Unauthorized and a JSON body to the response writer. It returns an error if there is an issue marshaling the body or writing it to the response writer.
type ConflictResponse ¶
type ConflictResponse struct {
Body v1.ErrorResponse
}
ConflictResponse represents an HTTP 409 with an ARM error payload.
This is used for delete operations.
func (*ConflictResponse) Apply ¶
func (r *ConflictResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply renders 409 Conflict HTTP response into http.ResponseWriter by setting Content-Type and serializing response.
type CreatedAsyncResponse ¶
CreatedAsyncResponse represents an HTTP 201 with a JSON payload and location header.
This is used when a request to create a new resource is processed asynchronously.
func (*CreatedAsyncResponse) Apply ¶
func (r *CreatedAsyncResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply renders Created HTTP Response into http.ResponseWriter with Location header for asynchronous operation and returns an error if it fails.
type CreatedResponse ¶
type CreatedResponse struct {
Body any
}
CreatedResponse represents an HTTP 201 with a JSON payload.
This is used when a request to create a new resource is processed synchronously.
func (*CreatedResponse) Apply ¶
func (r *CreatedResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply renders CreatedResponse to http.ResponseWriter by serializing empty body and set 201 Created response code and returns an error if any of these steps fail.
type InternalServerErrorResponse ¶
type InternalServerErrorResponse struct {
Body v1.ErrorResponse
}
func (*InternalServerErrorResponse) Apply ¶
func (r *InternalServerErrorResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply renders 500 InternalServerError HTTP response into http.ResponseWriter by setting Content-Type and serializing response.
type MethodNotAllowedResponse ¶
type MethodNotAllowedResponse struct {
Body v1.ErrorResponse
}
MethodNotAllowedResponse represents an HTTP 405 with an ARM error payload.
func (*MethodNotAllowedResponse) Apply ¶
func (r *MethodNotAllowedResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply renders a HTTP response by serializing Body in JSON and setting 405 response code and returns an error if it fails.
type NoContentResponse ¶
type NoContentResponse struct { }
NoContentResponse represents an HTTP 204.
This is used for delete operations.
func (*NoContentResponse) Apply ¶
func (r *NoContentResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply renders NoContent HTTP Response into http.ResponseWriter.
type NotFoundResponse ¶
type NotFoundResponse struct {
Body v1.ErrorResponse
}
NotFoundResponse represents an HTTP 404 with an ARM error payload.
This is used for GET operations when the response does not exist.
func (*NotFoundResponse) Apply ¶
func (r *NotFoundResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply renders 404 NotFound HTTP response into http.ResponseWriter by setting Content-Type and serializing response.
type OKResponse ¶
OKResponse represents an HTTP 200 with a JSON payload.
This is used when modification to an existing resource is processed synchronously.
func (*OKResponse) Apply ¶
func (r *OKResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply sets the response headers and body, and writes the response to the http.ResponseWriter with a status code of 200. If an error occurs while marshaling the body or writing the response, an error is returned.
type PreconditionFailedResponse ¶
type PreconditionFailedResponse struct {
Body v1.ErrorResponse
}
PreconditionFailedResponse represents an HTTP 412 with an ARM error payload.
func (*PreconditionFailedResponse) Apply ¶
func (r *PreconditionFailedResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply renders 412 PreconditionFailed HTTP response into http.ResponseWriter by setting Content-Type and serializing response.
type Response ¶
type Response interface { // Apply modifies the ResponseWriter to send the desired details back to the client. Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error }
Response represents a category of HTTP response (eg. OK with payload).
func NewAcceptedAsyncResponse ¶
NewAcceptedAsyncResponse creates an AcceptedAsyncResponse
func NewAsyncOperationResultResponse ¶
NewAsyncOperationResultResponse creates a new AsyncOperationResultResponse with the given headers.
func NewBadRequestARMResponse ¶
func NewBadRequestARMResponse(body v1.ErrorResponse) Response
NewBadRequestARMResponse creates a BadRequestResponse with error message.
func NewBadRequestResponse ¶
NewBadRequestResponse creates a BadRequestResponse with a given error message.
func NewClientAuthenticationFailedARMResponse ¶
func NewClientAuthenticationFailedARMResponse() Response
NewClientAuthenticationFailedARMResponse creates a ClientAuthenticationFailed Response with CodeInvalidAuthenticationInfo code and its message.
func NewConflictResponse ¶
NewConflictResponse creates a ConflictResponse for conflicting operations and resources.
func NewCreatedAsyncResponse ¶
NewCreatedAsyncResponse creates a new HTTP Response for asynchronous operation.
func NewCreatedResponse ¶
NewCreatedResponse creates a Created HTTP Response object with the given data.
func NewDependencyMissingResponse ¶
NewDependencyMissingResponse creates a DependencyMissingResponse with a given error message.
func NewInternalServerErrorARMResponse ¶
func NewInternalServerErrorARMResponse(body v1.ErrorResponse) Response
NewInternalServerErrorARMResponse creates a new InternalServerErrorResponse with the given error message.
func NewLinkedResourceUpdateErrorResponse ¶
func NewLinkedResourceUpdateErrorResponse(resourceID resources.ID, oldProp *rpv1.BasicResourceProperties, newProp *rpv1.BasicResourceProperties) Response
NewLinkedResourceUpdateErrorResponse represents a HTTP 400 with an error message when user updates environment id and application id.
func NewMethodNotAllowedResponse ¶
NewMethodNotAllowedResponse creates a MethodNotAllowedResponse with the given message and target resource.
func NewNoContentResponse ¶
func NewNoContentResponse() Response
NewNoContentResponse creates a new NoContentResponse object.
func NewNotFoundAPIVersionResponse ¶
func NewNotFoundAPIVersionResponse(resourceType string, namespace string, apiVersion string) Response
NewNotFoundAPIVersionResponse creates Response for unsupported api version. (message is consistent with ARM).
func NewNotFoundMessageResponse ¶
NewNotFoundMessageResponse represents an HTTP 404 with string message.
func NewNotFoundResponse ¶
NewNotFoundResponse creates a NotFoundResponse with resource id.
func NewOKResponse ¶
NewOKResponse creates an OKResponse that will write a 200 OK with the provided body as JSON. Set the body to nil to write an empty 200 OK.
func NewOKResponseWithHeaders ¶
NewOKResponseWithHeaders creates an OKResponse that will write a 200 OK with the provided body as JSON. Set the body to nil to write an empty 200 OK.
func NewPreconditionFailedResponse ¶
NewPreconditionFailedResponse creates a new PreconditionFailedResponse with the given target resource and message.
func NewValidationErrorResponse ¶
func NewValidationErrorResponse(errors validator.ValidationErrors) Response
NewValidationErrorResponse creates a BadRequest response for invalid API validation.
type ValidationErrorResponse ¶
type ValidationErrorResponse struct {
Body v1.ErrorResponse
}
ValidationErrorResponse represents an HTTP 400 with validation errors in ARM error format.
func (*ValidationErrorResponse) Apply ¶
func (r *ValidationErrorResponse) Apply(ctx context.Context, w http.ResponseWriter, req *http.Request) error
Apply renders BadRequest HTTP response into http.ResponseWriter by serializing invalid API validation error response and setting Content-Type.