github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/objects/objects_head_urlbuilder.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  // Code generated by go-swagger; DO NOT EDIT.
    13  
    14  package objects
    15  
    16  // This file was generated by the swagger tool.
    17  // Editing this file might prove futile when you re-run the generate command
    18  
    19  import (
    20  	"errors"
    21  	"net/url"
    22  	golangswaggerpaths "path"
    23  	"strings"
    24  
    25  	"github.com/go-openapi/strfmt"
    26  )
    27  
    28  // ObjectsHeadURL generates an URL for the objects head operation
    29  type ObjectsHeadURL struct {
    30  	ID strfmt.UUID
    31  
    32  	_basePath string
    33  	// avoid unkeyed usage
    34  	_ struct{}
    35  }
    36  
    37  // WithBasePath sets the base path for this url builder, only required when it's different from the
    38  // base path specified in the swagger spec.
    39  // When the value of the base path is an empty string
    40  func (o *ObjectsHeadURL) WithBasePath(bp string) *ObjectsHeadURL {
    41  	o.SetBasePath(bp)
    42  	return o
    43  }
    44  
    45  // SetBasePath sets the base path for this url builder, only required when it's different from the
    46  // base path specified in the swagger spec.
    47  // When the value of the base path is an empty string
    48  func (o *ObjectsHeadURL) SetBasePath(bp string) {
    49  	o._basePath = bp
    50  }
    51  
    52  // Build a url path and query string
    53  func (o *ObjectsHeadURL) Build() (*url.URL, error) {
    54  	var _result url.URL
    55  
    56  	var _path = "/objects/{id}"
    57  
    58  	id := o.ID.String()
    59  	if id != "" {
    60  		_path = strings.Replace(_path, "{id}", id, -1)
    61  	} else {
    62  		return nil, errors.New("id is required on ObjectsHeadURL")
    63  	}
    64  
    65  	_basePath := o._basePath
    66  	if _basePath == "" {
    67  		_basePath = "/v1"
    68  	}
    69  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    70  
    71  	return &_result, nil
    72  }
    73  
    74  // Must is a helper function to panic when the url builder returns an error
    75  func (o *ObjectsHeadURL) Must(u *url.URL, err error) *url.URL {
    76  	if err != nil {
    77  		panic(err)
    78  	}
    79  	if u == nil {
    80  		panic("url can't be nil")
    81  	}
    82  	return u
    83  }
    84  
    85  // String returns the string representation of the path with query string
    86  func (o *ObjectsHeadURL) String() string {
    87  	return o.Must(o.Build()).String()
    88  }
    89  
    90  // BuildFull builds a full url with scheme, host, path and query string
    91  func (o *ObjectsHeadURL) BuildFull(scheme, host string) (*url.URL, error) {
    92  	if scheme == "" {
    93  		return nil, errors.New("scheme is required for a full url on ObjectsHeadURL")
    94  	}
    95  	if host == "" {
    96  		return nil, errors.New("host is required for a full url on ObjectsHeadURL")
    97  	}
    98  
    99  	base, err := o.Build()
   100  	if err != nil {
   101  		return nil, err
   102  	}
   103  
   104  	base.Scheme = scheme
   105  	base.Host = host
   106  	return base, nil
   107  }
   108  
   109  // StringFull returns the string representation of a complete url
   110  func (o *ObjectsHeadURL) StringFull(scheme, host string) string {
   111  	return o.Must(o.BuildFull(scheme, host)).String()
   112  }