...

Source file src/github.com/prometheus/alertmanager/api/v2/client/silence/post_silences_responses.go

Documentation: github.com/prometheus/alertmanager/api/v2/client/silence

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright Prometheus Team
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  // http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  // Unless required by applicable law or agreed to in writing, software
    11  // distributed under the License is distributed on an "AS IS" BASIS,
    12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  //
    16  
    17  package silence
    18  
    19  // This file was generated by the swagger tool.
    20  // Editing this file might prove futile when you re-run the swagger generate command
    21  
    22  import (
    23  	"context"
    24  	"fmt"
    25  	"io"
    26  
    27  	"github.com/go-openapi/runtime"
    28  	"github.com/go-openapi/strfmt"
    29  	"github.com/go-openapi/swag"
    30  )
    31  
    32  // PostSilencesReader is a Reader for the PostSilences structure.
    33  type PostSilencesReader struct {
    34  	formats strfmt.Registry
    35  }
    36  
    37  // ReadResponse reads a server response into the received o.
    38  func (o *PostSilencesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    39  	switch response.Code() {
    40  	case 200:
    41  		result := NewPostSilencesOK()
    42  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    43  			return nil, err
    44  		}
    45  		return result, nil
    46  	case 400:
    47  		result := NewPostSilencesBadRequest()
    48  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    49  			return nil, err
    50  		}
    51  		return nil, result
    52  	case 404:
    53  		result := NewPostSilencesNotFound()
    54  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    55  			return nil, err
    56  		}
    57  		return nil, result
    58  	default:
    59  		return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
    60  	}
    61  }
    62  
    63  // NewPostSilencesOK creates a PostSilencesOK with default headers values
    64  func NewPostSilencesOK() *PostSilencesOK {
    65  	return &PostSilencesOK{}
    66  }
    67  
    68  /*
    69  PostSilencesOK describes a response with status code 200, with default header values.
    70  
    71  Create / update silence response
    72  */
    73  type PostSilencesOK struct {
    74  	Payload *PostSilencesOKBody
    75  }
    76  
    77  // IsSuccess returns true when this post silences o k response has a 2xx status code
    78  func (o *PostSilencesOK) IsSuccess() bool {
    79  	return true
    80  }
    81  
    82  // IsRedirect returns true when this post silences o k response has a 3xx status code
    83  func (o *PostSilencesOK) IsRedirect() bool {
    84  	return false
    85  }
    86  
    87  // IsClientError returns true when this post silences o k response has a 4xx status code
    88  func (o *PostSilencesOK) IsClientError() bool {
    89  	return false
    90  }
    91  
    92  // IsServerError returns true when this post silences o k response has a 5xx status code
    93  func (o *PostSilencesOK) IsServerError() bool {
    94  	return false
    95  }
    96  
    97  // IsCode returns true when this post silences o k response a status code equal to that given
    98  func (o *PostSilencesOK) IsCode(code int) bool {
    99  	return code == 200
   100  }
   101  
   102  func (o *PostSilencesOK) Error() string {
   103  	return fmt.Sprintf("[POST /silences][%d] postSilencesOK  %+v", 200, o.Payload)
   104  }
   105  
   106  func (o *PostSilencesOK) String() string {
   107  	return fmt.Sprintf("[POST /silences][%d] postSilencesOK  %+v", 200, o.Payload)
   108  }
   109  
   110  func (o *PostSilencesOK) GetPayload() *PostSilencesOKBody {
   111  	return o.Payload
   112  }
   113  
   114  func (o *PostSilencesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   115  
   116  	o.Payload = new(PostSilencesOKBody)
   117  
   118  	// response payload
   119  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   120  		return err
   121  	}
   122  
   123  	return nil
   124  }
   125  
   126  // NewPostSilencesBadRequest creates a PostSilencesBadRequest with default headers values
   127  func NewPostSilencesBadRequest() *PostSilencesBadRequest {
   128  	return &PostSilencesBadRequest{}
   129  }
   130  
   131  /*
   132  PostSilencesBadRequest describes a response with status code 400, with default header values.
   133  
   134  Bad request
   135  */
   136  type PostSilencesBadRequest struct {
   137  	Payload string
   138  }
   139  
   140  // IsSuccess returns true when this post silences bad request response has a 2xx status code
   141  func (o *PostSilencesBadRequest) IsSuccess() bool {
   142  	return false
   143  }
   144  
   145  // IsRedirect returns true when this post silences bad request response has a 3xx status code
   146  func (o *PostSilencesBadRequest) IsRedirect() bool {
   147  	return false
   148  }
   149  
   150  // IsClientError returns true when this post silences bad request response has a 4xx status code
   151  func (o *PostSilencesBadRequest) IsClientError() bool {
   152  	return true
   153  }
   154  
   155  // IsServerError returns true when this post silences bad request response has a 5xx status code
   156  func (o *PostSilencesBadRequest) IsServerError() bool {
   157  	return false
   158  }
   159  
   160  // IsCode returns true when this post silences bad request response a status code equal to that given
   161  func (o *PostSilencesBadRequest) IsCode(code int) bool {
   162  	return code == 400
   163  }
   164  
   165  func (o *PostSilencesBadRequest) Error() string {
   166  	return fmt.Sprintf("[POST /silences][%d] postSilencesBadRequest  %+v", 400, o.Payload)
   167  }
   168  
   169  func (o *PostSilencesBadRequest) String() string {
   170  	return fmt.Sprintf("[POST /silences][%d] postSilencesBadRequest  %+v", 400, o.Payload)
   171  }
   172  
   173  func (o *PostSilencesBadRequest) GetPayload() string {
   174  	return o.Payload
   175  }
   176  
   177  func (o *PostSilencesBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   178  
   179  	// response payload
   180  	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
   181  		return err
   182  	}
   183  
   184  	return nil
   185  }
   186  
   187  // NewPostSilencesNotFound creates a PostSilencesNotFound with default headers values
   188  func NewPostSilencesNotFound() *PostSilencesNotFound {
   189  	return &PostSilencesNotFound{}
   190  }
   191  
   192  /*
   193  PostSilencesNotFound describes a response with status code 404, with default header values.
   194  
   195  A silence with the specified ID was not found
   196  */
   197  type PostSilencesNotFound struct {
   198  	Payload string
   199  }
   200  
   201  // IsSuccess returns true when this post silences not found response has a 2xx status code
   202  func (o *PostSilencesNotFound) IsSuccess() bool {
   203  	return false
   204  }
   205  
   206  // IsRedirect returns true when this post silences not found response has a 3xx status code
   207  func (o *PostSilencesNotFound) IsRedirect() bool {
   208  	return false
   209  }
   210  
   211  // IsClientError returns true when this post silences not found response has a 4xx status code
   212  func (o *PostSilencesNotFound) IsClientError() bool {
   213  	return true
   214  }
   215  
   216  // IsServerError returns true when this post silences not found response has a 5xx status code
   217  func (o *PostSilencesNotFound) IsServerError() bool {
   218  	return false
   219  }
   220  
   221  // IsCode returns true when this post silences not found response a status code equal to that given
   222  func (o *PostSilencesNotFound) IsCode(code int) bool {
   223  	return code == 404
   224  }
   225  
   226  func (o *PostSilencesNotFound) Error() string {
   227  	return fmt.Sprintf("[POST /silences][%d] postSilencesNotFound  %+v", 404, o.Payload)
   228  }
   229  
   230  func (o *PostSilencesNotFound) String() string {
   231  	return fmt.Sprintf("[POST /silences][%d] postSilencesNotFound  %+v", 404, o.Payload)
   232  }
   233  
   234  func (o *PostSilencesNotFound) GetPayload() string {
   235  	return o.Payload
   236  }
   237  
   238  func (o *PostSilencesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   239  
   240  	// response payload
   241  	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
   242  		return err
   243  	}
   244  
   245  	return nil
   246  }
   247  
   248  /*
   249  PostSilencesOKBody post silences o k body
   250  swagger:model PostSilencesOKBody
   251  */
   252  type PostSilencesOKBody struct {
   253  
   254  	// silence ID
   255  	SilenceID string `json:"silenceID,omitempty"`
   256  }
   257  
   258  // Validate validates this post silences o k body
   259  func (o *PostSilencesOKBody) Validate(formats strfmt.Registry) error {
   260  	return nil
   261  }
   262  
   263  // ContextValidate validates this post silences o k body based on context it is used
   264  func (o *PostSilencesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   265  	return nil
   266  }
   267  
   268  // MarshalBinary interface implementation
   269  func (o *PostSilencesOKBody) MarshalBinary() ([]byte, error) {
   270  	if o == nil {
   271  		return nil, nil
   272  	}
   273  	return swag.WriteJSON(o)
   274  }
   275  
   276  // UnmarshalBinary interface implementation
   277  func (o *PostSilencesOKBody) UnmarshalBinary(b []byte) error {
   278  	var res PostSilencesOKBody
   279  	if err := swag.ReadJSON(b, &res); err != nil {
   280  		return err
   281  	}
   282  	*o = res
   283  	return nil
   284  }
   285  

View as plain text