github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/objects/objects_class_get_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  // ObjectsClassGetURL generates an URL for the objects class get operation
    29  type ObjectsClassGetURL struct {
    30  	ClassName string
    31  	ID        strfmt.UUID
    32  
    33  	ConsistencyLevel *string
    34  	Include          *string
    35  	NodeName         *string
    36  	Tenant           *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 *ObjectsClassGetURL) WithBasePath(bp string) *ObjectsClassGetURL {
    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 *ObjectsClassGetURL) SetBasePath(bp string) {
    55  	o._basePath = bp
    56  }
    57  
    58  // Build a url path and query string
    59  func (o *ObjectsClassGetURL) Build() (*url.URL, error) {
    60  	var _result url.URL
    61  
    62  	var _path = "/objects/{className}/{id}"
    63  
    64  	className := o.ClassName
    65  	if className != "" {
    66  		_path = strings.Replace(_path, "{className}", className, -1)
    67  	} else {
    68  		return nil, errors.New("className is required on ObjectsClassGetURL")
    69  	}
    70  
    71  	id := o.ID.String()
    72  	if id != "" {
    73  		_path = strings.Replace(_path, "{id}", id, -1)
    74  	} else {
    75  		return nil, errors.New("id is required on ObjectsClassGetURL")
    76  	}
    77  
    78  	_basePath := o._basePath
    79  	if _basePath == "" {
    80  		_basePath = "/v1"
    81  	}
    82  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    83  
    84  	qs := make(url.Values)
    85  
    86  	var consistencyLevelQ string
    87  	if o.ConsistencyLevel != nil {
    88  		consistencyLevelQ = *o.ConsistencyLevel
    89  	}
    90  	if consistencyLevelQ != "" {
    91  		qs.Set("consistency_level", consistencyLevelQ)
    92  	}
    93  
    94  	var includeQ string
    95  	if o.Include != nil {
    96  		includeQ = *o.Include
    97  	}
    98  	if includeQ != "" {
    99  		qs.Set("include", includeQ)
   100  	}
   101  
   102  	var nodeNameQ string
   103  	if o.NodeName != nil {
   104  		nodeNameQ = *o.NodeName
   105  	}
   106  	if nodeNameQ != "" {
   107  		qs.Set("node_name", nodeNameQ)
   108  	}
   109  
   110  	var tenantQ string
   111  	if o.Tenant != nil {
   112  		tenantQ = *o.Tenant
   113  	}
   114  	if tenantQ != "" {
   115  		qs.Set("tenant", tenantQ)
   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 *ObjectsClassGetURL) 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 *ObjectsClassGetURL) 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 *ObjectsClassGetURL) BuildFull(scheme, host string) (*url.URL, error) {
   141  	if scheme == "" {
   142  		return nil, errors.New("scheme is required for a full url on ObjectsClassGetURL")
   143  	}
   144  	if host == "" {
   145  		return nil, errors.New("host is required for a full url on ObjectsClassGetURL")
   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 *ObjectsClassGetURL) StringFull(scheme, host string) string {
   160  	return o.Must(o.BuildFull(scheme, host)).String()
   161  }