...

Source file src/github.com/prometheus/alertmanager/api/v2/restapi/operations/alertgroup/get_alert_groups_urlbuilder.go

Documentation: github.com/prometheus/alertmanager/api/v2/restapi/operations/alertgroup

     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 alertgroup
    18  
    19  // This file was generated by the swagger tool.
    20  // Editing this file might prove futile when you re-run the generate command
    21  
    22  import (
    23  	"errors"
    24  	"net/url"
    25  	golangswaggerpaths "path"
    26  
    27  	"github.com/go-openapi/swag"
    28  )
    29  
    30  // GetAlertGroupsURL generates an URL for the get alert groups operation
    31  type GetAlertGroupsURL struct {
    32  	Active    *bool
    33  	Filter    []string
    34  	Inhibited *bool
    35  	Receiver  *string
    36  	Silenced  *bool
    37  
    38  	_basePath string
    39  	// avoid unkeyed usage
    40  	_ struct{}
    41  }
    42  
    43  // WithBasePath sets the base path for this url builder, only required when it's different from the
    44  // base path specified in the swagger spec.
    45  // When the value of the base path is an empty string
    46  func (o *GetAlertGroupsURL) WithBasePath(bp string) *GetAlertGroupsURL {
    47  	o.SetBasePath(bp)
    48  	return o
    49  }
    50  
    51  // SetBasePath sets the base path for this url builder, only required when it's different from the
    52  // base path specified in the swagger spec.
    53  // When the value of the base path is an empty string
    54  func (o *GetAlertGroupsURL) SetBasePath(bp string) {
    55  	o._basePath = bp
    56  }
    57  
    58  // Build a url path and query string
    59  func (o *GetAlertGroupsURL) Build() (*url.URL, error) {
    60  	var _result url.URL
    61  
    62  	var _path = "/alerts/groups"
    63  
    64  	_basePath := o._basePath
    65  	if _basePath == "" {
    66  		_basePath = "/api/v2/"
    67  	}
    68  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    69  
    70  	qs := make(url.Values)
    71  
    72  	var activeQ string
    73  	if o.Active != nil {
    74  		activeQ = swag.FormatBool(*o.Active)
    75  	}
    76  	if activeQ != "" {
    77  		qs.Set("active", activeQ)
    78  	}
    79  
    80  	var filterIR []string
    81  	for _, filterI := range o.Filter {
    82  		filterIS := filterI
    83  		if filterIS != "" {
    84  			filterIR = append(filterIR, filterIS)
    85  		}
    86  	}
    87  
    88  	filter := swag.JoinByFormat(filterIR, "multi")
    89  
    90  	for _, qsv := range filter {
    91  		qs.Add("filter", qsv)
    92  	}
    93  
    94  	var inhibitedQ string
    95  	if o.Inhibited != nil {
    96  		inhibitedQ = swag.FormatBool(*o.Inhibited)
    97  	}
    98  	if inhibitedQ != "" {
    99  		qs.Set("inhibited", inhibitedQ)
   100  	}
   101  
   102  	var receiverQ string
   103  	if o.Receiver != nil {
   104  		receiverQ = *o.Receiver
   105  	}
   106  	if receiverQ != "" {
   107  		qs.Set("receiver", receiverQ)
   108  	}
   109  
   110  	var silencedQ string
   111  	if o.Silenced != nil {
   112  		silencedQ = swag.FormatBool(*o.Silenced)
   113  	}
   114  	if silencedQ != "" {
   115  		qs.Set("silenced", silencedQ)
   116  	}
   117  
   118  	_result.RawQuery = qs.Encode()
   119  
   120  	return &_result, nil
   121  }
   122  
   123  // Must is a helper function to panic when the url builder returns an error
   124  func (o *GetAlertGroupsURL) Must(u *url.URL, err error) *url.URL {
   125  	if err != nil {
   126  		panic(err)
   127  	}
   128  	if u == nil {
   129  		panic("url can't be nil")
   130  	}
   131  	return u
   132  }
   133  
   134  // String returns the string representation of the path with query string
   135  func (o *GetAlertGroupsURL) String() string {
   136  	return o.Must(o.Build()).String()
   137  }
   138  
   139  // BuildFull builds a full url with scheme, host, path and query string
   140  func (o *GetAlertGroupsURL) BuildFull(scheme, host string) (*url.URL, error) {
   141  	if scheme == "" {
   142  		return nil, errors.New("scheme is required for a full url on GetAlertGroupsURL")
   143  	}
   144  	if host == "" {
   145  		return nil, errors.New("host is required for a full url on GetAlertGroupsURL")
   146  	}
   147  
   148  	base, err := o.Build()
   149  	if err != nil {
   150  		return nil, err
   151  	}
   152  
   153  	base.Scheme = scheme
   154  	base.Host = host
   155  	return base, nil
   156  }
   157  
   158  // StringFull returns the string representation of a complete url
   159  func (o *GetAlertGroupsURL) StringFull(scheme, host string) string {
   160  	return o.Must(o.BuildFull(scheme, host)).String()
   161  }
   162  

View as plain text