github.com/minio/console@v1.4.1/api/operations/release/list_releases_urlbuilder.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // This file is part of MinIO Console Server
     4  // Copyright (c) 2023 MinIO, Inc.
     5  //
     6  // This program is free software: you can redistribute it and/or modify
     7  // it under the terms of the GNU Affero General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // This program is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  // GNU Affero General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU Affero General Public License
    17  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18  //
    19  
    20  package release
    21  
    22  // This file was generated by the swagger tool.
    23  // Editing this file might prove futile when you re-run the generate command
    24  
    25  import (
    26  	"errors"
    27  	"net/url"
    28  	golangswaggerpaths "path"
    29  )
    30  
    31  // ListReleasesURL generates an URL for the list releases operation
    32  type ListReleasesURL struct {
    33  	Current *string
    34  	Filter  *string
    35  	Repo    string
    36  	Search  *string
    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 *ListReleasesURL) WithBasePath(bp string) *ListReleasesURL {
    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 *ListReleasesURL) SetBasePath(bp string) {
    55  	o._basePath = bp
    56  }
    57  
    58  // Build a url path and query string
    59  func (o *ListReleasesURL) Build() (*url.URL, error) {
    60  	var _result url.URL
    61  
    62  	var _path = "/releases"
    63  
    64  	_basePath := o._basePath
    65  	if _basePath == "" {
    66  		_basePath = "/api/v1"
    67  	}
    68  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    69  
    70  	qs := make(url.Values)
    71  
    72  	var currentQ string
    73  	if o.Current != nil {
    74  		currentQ = *o.Current
    75  	}
    76  	if currentQ != "" {
    77  		qs.Set("current", currentQ)
    78  	}
    79  
    80  	var filterQ string
    81  	if o.Filter != nil {
    82  		filterQ = *o.Filter
    83  	}
    84  	if filterQ != "" {
    85  		qs.Set("filter", filterQ)
    86  	}
    87  
    88  	repoQ := o.Repo
    89  	if repoQ != "" {
    90  		qs.Set("repo", repoQ)
    91  	}
    92  
    93  	var searchQ string
    94  	if o.Search != nil {
    95  		searchQ = *o.Search
    96  	}
    97  	if searchQ != "" {
    98  		qs.Set("search", searchQ)
    99  	}
   100  
   101  	_result.RawQuery = qs.Encode()
   102  
   103  	return &_result, nil
   104  }
   105  
   106  // Must is a helper function to panic when the url builder returns an error
   107  func (o *ListReleasesURL) Must(u *url.URL, err error) *url.URL {
   108  	if err != nil {
   109  		panic(err)
   110  	}
   111  	if u == nil {
   112  		panic("url can't be nil")
   113  	}
   114  	return u
   115  }
   116  
   117  // String returns the string representation of the path with query string
   118  func (o *ListReleasesURL) String() string {
   119  	return o.Must(o.Build()).String()
   120  }
   121  
   122  // BuildFull builds a full url with scheme, host, path and query string
   123  func (o *ListReleasesURL) BuildFull(scheme, host string) (*url.URL, error) {
   124  	if scheme == "" {
   125  		return nil, errors.New("scheme is required for a full url on ListReleasesURL")
   126  	}
   127  	if host == "" {
   128  		return nil, errors.New("host is required for a full url on ListReleasesURL")
   129  	}
   130  
   131  	base, err := o.Build()
   132  	if err != nil {
   133  		return nil, err
   134  	}
   135  
   136  	base.Scheme = scheme
   137  	base.Host = host
   138  	return base, nil
   139  }
   140  
   141  // StringFull returns the string representation of a complete url
   142  func (o *ListReleasesURL) StringFull(scheme, host string) string {
   143  	return o.Must(o.BuildFull(scheme, host)).String()
   144  }