...

Source file src/github.com/prometheus/alertmanager/api/v2/restapi/operations/silence/get_silence_urlbuilder.go

Documentation: github.com/prometheus/alertmanager/api/v2/restapi/operations/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 generate command
    21  
    22  import (
    23  	"errors"
    24  	"net/url"
    25  	golangswaggerpaths "path"
    26  	"strings"
    27  
    28  	"github.com/go-openapi/strfmt"
    29  )
    30  
    31  // GetSilenceURL generates an URL for the get silence operation
    32  type GetSilenceURL struct {
    33  	SilenceID strfmt.UUID
    34  
    35  	_basePath string
    36  	// avoid unkeyed usage
    37  	_ struct{}
    38  }
    39  
    40  // WithBasePath sets the base path for this url builder, only required when it's different from the
    41  // base path specified in the swagger spec.
    42  // When the value of the base path is an empty string
    43  func (o *GetSilenceURL) WithBasePath(bp string) *GetSilenceURL {
    44  	o.SetBasePath(bp)
    45  	return o
    46  }
    47  
    48  // SetBasePath sets the base path for this url builder, only required when it's different from the
    49  // base path specified in the swagger spec.
    50  // When the value of the base path is an empty string
    51  func (o *GetSilenceURL) SetBasePath(bp string) {
    52  	o._basePath = bp
    53  }
    54  
    55  // Build a url path and query string
    56  func (o *GetSilenceURL) Build() (*url.URL, error) {
    57  	var _result url.URL
    58  
    59  	var _path = "/silence/{silenceID}"
    60  
    61  	silenceID := o.SilenceID.String()
    62  	if silenceID != "" {
    63  		_path = strings.Replace(_path, "{silenceID}", silenceID, -1)
    64  	} else {
    65  		return nil, errors.New("silenceId is required on GetSilenceURL")
    66  	}
    67  
    68  	_basePath := o._basePath
    69  	if _basePath == "" {
    70  		_basePath = "/api/v2/"
    71  	}
    72  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    73  
    74  	return &_result, nil
    75  }
    76  
    77  // Must is a helper function to panic when the url builder returns an error
    78  func (o *GetSilenceURL) Must(u *url.URL, err error) *url.URL {
    79  	if err != nil {
    80  		panic(err)
    81  	}
    82  	if u == nil {
    83  		panic("url can't be nil")
    84  	}
    85  	return u
    86  }
    87  
    88  // String returns the string representation of the path with query string
    89  func (o *GetSilenceURL) String() string {
    90  	return o.Must(o.Build()).String()
    91  }
    92  
    93  // BuildFull builds a full url with scheme, host, path and query string
    94  func (o *GetSilenceURL) BuildFull(scheme, host string) (*url.URL, error) {
    95  	if scheme == "" {
    96  		return nil, errors.New("scheme is required for a full url on GetSilenceURL")
    97  	}
    98  	if host == "" {
    99  		return nil, errors.New("host is required for a full url on GetSilenceURL")
   100  	}
   101  
   102  	base, err := o.Build()
   103  	if err != nil {
   104  		return nil, err
   105  	}
   106  
   107  	base.Scheme = scheme
   108  	base.Host = host
   109  	return base, nil
   110  }
   111  
   112  // StringFull returns the string representation of a complete url
   113  func (o *GetSilenceURL) StringFull(scheme, host string) string {
   114  	return o.Must(o.BuildFull(scheme, host)).String()
   115  }
   116  

View as plain text