...

Source file src/github.com/prometheus/alertmanager/api/v2/client/alert/alert_client.go

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

     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 alert
    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  	"fmt"
    24  
    25  	"github.com/go-openapi/runtime"
    26  	"github.com/go-openapi/strfmt"
    27  )
    28  
    29  // New creates a new alert API client.
    30  func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
    31  	return &Client{transport: transport, formats: formats}
    32  }
    33  
    34  /*
    35  Client for alert API
    36  */
    37  type Client struct {
    38  	transport runtime.ClientTransport
    39  	formats   strfmt.Registry
    40  }
    41  
    42  // ClientOption is the option for Client methods
    43  type ClientOption func(*runtime.ClientOperation)
    44  
    45  // ClientService is the interface for Client methods
    46  type ClientService interface {
    47  	GetAlerts(params *GetAlertsParams, opts ...ClientOption) (*GetAlertsOK, error)
    48  
    49  	PostAlerts(params *PostAlertsParams, opts ...ClientOption) (*PostAlertsOK, error)
    50  
    51  	SetTransport(transport runtime.ClientTransport)
    52  }
    53  
    54  /*
    55  GetAlerts Get a list of alerts
    56  */
    57  func (a *Client) GetAlerts(params *GetAlertsParams, opts ...ClientOption) (*GetAlertsOK, error) {
    58  	// TODO: Validate the params before sending
    59  	if params == nil {
    60  		params = NewGetAlertsParams()
    61  	}
    62  	op := &runtime.ClientOperation{
    63  		ID:                 "getAlerts",
    64  		Method:             "GET",
    65  		PathPattern:        "/alerts",
    66  		ProducesMediaTypes: []string{"application/json"},
    67  		ConsumesMediaTypes: []string{"application/json"},
    68  		Schemes:            []string{"http"},
    69  		Params:             params,
    70  		Reader:             &GetAlertsReader{formats: a.formats},
    71  		Context:            params.Context,
    72  		Client:             params.HTTPClient,
    73  	}
    74  	for _, opt := range opts {
    75  		opt(op)
    76  	}
    77  
    78  	result, err := a.transport.Submit(op)
    79  	if err != nil {
    80  		return nil, err
    81  	}
    82  	success, ok := result.(*GetAlertsOK)
    83  	if ok {
    84  		return success, nil
    85  	}
    86  	// unexpected success response
    87  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    88  	msg := fmt.Sprintf("unexpected success response for getAlerts: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    89  	panic(msg)
    90  }
    91  
    92  /*
    93  PostAlerts Create new Alerts
    94  */
    95  func (a *Client) PostAlerts(params *PostAlertsParams, opts ...ClientOption) (*PostAlertsOK, error) {
    96  	// TODO: Validate the params before sending
    97  	if params == nil {
    98  		params = NewPostAlertsParams()
    99  	}
   100  	op := &runtime.ClientOperation{
   101  		ID:                 "postAlerts",
   102  		Method:             "POST",
   103  		PathPattern:        "/alerts",
   104  		ProducesMediaTypes: []string{"application/json"},
   105  		ConsumesMediaTypes: []string{"application/json"},
   106  		Schemes:            []string{"http"},
   107  		Params:             params,
   108  		Reader:             &PostAlertsReader{formats: a.formats},
   109  		Context:            params.Context,
   110  		Client:             params.HTTPClient,
   111  	}
   112  	for _, opt := range opts {
   113  		opt(op)
   114  	}
   115  
   116  	result, err := a.transport.Submit(op)
   117  	if err != nil {
   118  		return nil, err
   119  	}
   120  	success, ok := result.(*PostAlertsOK)
   121  	if ok {
   122  		return success, nil
   123  	}
   124  	// unexpected success response
   125  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   126  	msg := fmt.Sprintf("unexpected success response for postAlerts: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   127  	panic(msg)
   128  }
   129  
   130  // SetTransport changes the transport on the client
   131  func (a *Client) SetTransport(transport runtime.ClientTransport) {
   132  	a.transport = transport
   133  }
   134  

View as plain text