...

Source file src/github.com/prometheus/alertmanager/api/v2/client/general/general_client.go

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

     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 general
    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 general 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 general 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  	GetStatus(params *GetStatusParams, opts ...ClientOption) (*GetStatusOK, error)
    48  
    49  	SetTransport(transport runtime.ClientTransport)
    50  }
    51  
    52  /*
    53  GetStatus Get current status of an Alertmanager instance and its cluster
    54  */
    55  func (a *Client) GetStatus(params *GetStatusParams, opts ...ClientOption) (*GetStatusOK, error) {
    56  	// TODO: Validate the params before sending
    57  	if params == nil {
    58  		params = NewGetStatusParams()
    59  	}
    60  	op := &runtime.ClientOperation{
    61  		ID:                 "getStatus",
    62  		Method:             "GET",
    63  		PathPattern:        "/status",
    64  		ProducesMediaTypes: []string{"application/json"},
    65  		ConsumesMediaTypes: []string{"application/json"},
    66  		Schemes:            []string{"http"},
    67  		Params:             params,
    68  		Reader:             &GetStatusReader{formats: a.formats},
    69  		Context:            params.Context,
    70  		Client:             params.HTTPClient,
    71  	}
    72  	for _, opt := range opts {
    73  		opt(op)
    74  	}
    75  
    76  	result, err := a.transport.Submit(op)
    77  	if err != nil {
    78  		return nil, err
    79  	}
    80  	success, ok := result.(*GetStatusOK)
    81  	if ok {
    82  		return success, nil
    83  	}
    84  	// unexpected success response
    85  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    86  	msg := fmt.Sprintf("unexpected success response for getStatus: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    87  	panic(msg)
    88  }
    89  
    90  // SetTransport changes the transport on the client
    91  func (a *Client) SetTransport(transport runtime.ClientTransport) {
    92  	a.transport = transport
    93  }
    94  

View as plain text