github.com/minio/console@v1.4.1/api/operations/logging/log_search_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 logging
    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  	"github.com/go-openapi/swag"
    31  )
    32  
    33  // LogSearchURL generates an URL for the log search operation
    34  type LogSearchURL struct {
    35  	Fp        []string
    36  	Order     *string
    37  	PageNo    *int32
    38  	PageSize  *int32
    39  	TimeEnd   *string
    40  	TimeStart *string
    41  
    42  	_basePath string
    43  	// avoid unkeyed usage
    44  	_ struct{}
    45  }
    46  
    47  // WithBasePath sets the base path for this url builder, only required when it's different from the
    48  // base path specified in the swagger spec.
    49  // When the value of the base path is an empty string
    50  func (o *LogSearchURL) WithBasePath(bp string) *LogSearchURL {
    51  	o.SetBasePath(bp)
    52  	return o
    53  }
    54  
    55  // SetBasePath sets the base path for this url builder, only required when it's different from the
    56  // base path specified in the swagger spec.
    57  // When the value of the base path is an empty string
    58  func (o *LogSearchURL) SetBasePath(bp string) {
    59  	o._basePath = bp
    60  }
    61  
    62  // Build a url path and query string
    63  func (o *LogSearchURL) Build() (*url.URL, error) {
    64  	var _result url.URL
    65  
    66  	var _path = "/logs/search"
    67  
    68  	_basePath := o._basePath
    69  	if _basePath == "" {
    70  		_basePath = "/api/v1"
    71  	}
    72  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    73  
    74  	qs := make(url.Values)
    75  
    76  	var fpIR []string
    77  	for _, fpI := range o.Fp {
    78  		fpIS := fpI
    79  		if fpIS != "" {
    80  			fpIR = append(fpIR, fpIS)
    81  		}
    82  	}
    83  
    84  	fp := swag.JoinByFormat(fpIR, "multi")
    85  
    86  	for _, qsv := range fp {
    87  		qs.Add("fp", qsv)
    88  	}
    89  
    90  	var orderQ string
    91  	if o.Order != nil {
    92  		orderQ = *o.Order
    93  	}
    94  	if orderQ != "" {
    95  		qs.Set("order", orderQ)
    96  	}
    97  
    98  	var pageNoQ string
    99  	if o.PageNo != nil {
   100  		pageNoQ = swag.FormatInt32(*o.PageNo)
   101  	}
   102  	if pageNoQ != "" {
   103  		qs.Set("pageNo", pageNoQ)
   104  	}
   105  
   106  	var pageSizeQ string
   107  	if o.PageSize != nil {
   108  		pageSizeQ = swag.FormatInt32(*o.PageSize)
   109  	}
   110  	if pageSizeQ != "" {
   111  		qs.Set("pageSize", pageSizeQ)
   112  	}
   113  
   114  	var timeEndQ string
   115  	if o.TimeEnd != nil {
   116  		timeEndQ = *o.TimeEnd
   117  	}
   118  	if timeEndQ != "" {
   119  		qs.Set("timeEnd", timeEndQ)
   120  	}
   121  
   122  	var timeStartQ string
   123  	if o.TimeStart != nil {
   124  		timeStartQ = *o.TimeStart
   125  	}
   126  	if timeStartQ != "" {
   127  		qs.Set("timeStart", timeStartQ)
   128  	}
   129  
   130  	_result.RawQuery = qs.Encode()
   131  
   132  	return &_result, nil
   133  }
   134  
   135  // Must is a helper function to panic when the url builder returns an error
   136  func (o *LogSearchURL) Must(u *url.URL, err error) *url.URL {
   137  	if err != nil {
   138  		panic(err)
   139  	}
   140  	if u == nil {
   141  		panic("url can't be nil")
   142  	}
   143  	return u
   144  }
   145  
   146  // String returns the string representation of the path with query string
   147  func (o *LogSearchURL) String() string {
   148  	return o.Must(o.Build()).String()
   149  }
   150  
   151  // BuildFull builds a full url with scheme, host, path and query string
   152  func (o *LogSearchURL) BuildFull(scheme, host string) (*url.URL, error) {
   153  	if scheme == "" {
   154  		return nil, errors.New("scheme is required for a full url on LogSearchURL")
   155  	}
   156  	if host == "" {
   157  		return nil, errors.New("host is required for a full url on LogSearchURL")
   158  	}
   159  
   160  	base, err := o.Build()
   161  	if err != nil {
   162  		return nil, err
   163  	}
   164  
   165  	base.Scheme = scheme
   166  	base.Host = host
   167  	return base, nil
   168  }
   169  
   170  // StringFull returns the string representation of a complete url
   171  func (o *LogSearchURL) StringFull(scheme, host string) string {
   172  	return o.Must(o.BuildFull(scheme, host)).String()
   173  }