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
17package client
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
22import (
23	"github.com/go-openapi/runtime"
24	httptransport "github.com/go-openapi/runtime/client"
25	"github.com/go-openapi/strfmt"
26
27	"github.com/prometheus/alertmanager/api/v2/client/alert"
28	"github.com/prometheus/alertmanager/api/v2/client/alertgroup"
29	"github.com/prometheus/alertmanager/api/v2/client/general"
30	"github.com/prometheus/alertmanager/api/v2/client/receiver"
31	"github.com/prometheus/alertmanager/api/v2/client/silence"
32)
33
34// Default alertmanager HTTP client.
35var Default = NewHTTPClient(nil)
36
37const (
38	// DefaultHost is the default Host
39	// found in Meta (info) section of spec file
40	DefaultHost string = "localhost"
41	// DefaultBasePath is the default BasePath
42	// found in Meta (info) section of spec file
43	DefaultBasePath string = "/api/v2/"
44)
45
46// DefaultSchemes are the default schemes found in Meta (info) section of spec file
47var DefaultSchemes = []string{"http"}
48
49// NewHTTPClient creates a new alertmanager HTTP client.
50func NewHTTPClient(formats strfmt.Registry) *Alertmanager {
51	return NewHTTPClientWithConfig(formats, nil)
52}
53
54// NewHTTPClientWithConfig creates a new alertmanager HTTP client,
55// using a customizable transport config.
56func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *Alertmanager {
57	// ensure nullable parameters have default
58	if cfg == nil {
59		cfg = DefaultTransportConfig()
60	}
61
62	// create transport and client
63	transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
64	return New(transport, formats)
65}
66
67// New creates a new alertmanager client
68func New(transport runtime.ClientTransport, formats strfmt.Registry) *Alertmanager {
69	// ensure nullable parameters have default
70	if formats == nil {
71		formats = strfmt.Default
72	}
73
74	cli := new(Alertmanager)
75	cli.Transport = transport
76	cli.Alert = alert.New(transport, formats)
77	cli.Alertgroup = alertgroup.New(transport, formats)
78	cli.General = general.New(transport, formats)
79	cli.Receiver = receiver.New(transport, formats)
80	cli.Silence = silence.New(transport, formats)
81	return cli
82}
83
84// DefaultTransportConfig creates a TransportConfig with the
85// default settings taken from the meta section of the spec file.
86func DefaultTransportConfig() *TransportConfig {
87	return &TransportConfig{
88		Host:     DefaultHost,
89		BasePath: DefaultBasePath,
90		Schemes:  DefaultSchemes,
91	}
92}
93
94// TransportConfig contains the transport related info,
95// found in the meta section of the spec file.
96type TransportConfig struct {
97	Host     string
98	BasePath string
99	Schemes  []string
100}
101
102// WithHost overrides the default host,
103// provided by the meta section of the spec file.
104func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
105	cfg.Host = host
106	return cfg
107}
108
109// WithBasePath overrides the default basePath,
110// provided by the meta section of the spec file.
111func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
112	cfg.BasePath = basePath
113	return cfg
114}
115
116// WithSchemes overrides the default schemes,
117// provided by the meta section of the spec file.
118func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
119	cfg.Schemes = schemes
120	return cfg
121}
122
123// Alertmanager is a client for alertmanager
124type Alertmanager struct {
125	Alert alert.ClientService
126
127	Alertgroup alertgroup.ClientService
128
129	General general.ClientService
130
131	Receiver receiver.ClientService
132
133	Silence silence.ClientService
134
135	Transport runtime.ClientTransport
136}
137
138// SetTransport changes the transport on the client and all its subresources
139func (c *Alertmanager) SetTransport(transport runtime.ClientTransport) {
140	c.Transport = transport
141	c.Alert.SetTransport(transport)
142	c.Alertgroup.SetTransport(transport)
143	c.General.SetTransport(transport)
144	c.Receiver.SetTransport(transport)
145	c.Silence.SetTransport(transport)
146}
147