github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/objects/objects_class_references_create_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  // ObjectsClassReferencesCreateURL generates an URL for the objects class references create operation
    29  type ObjectsClassReferencesCreateURL struct {
    30  	ClassName    string
    31  	ID           strfmt.UUID
    32  	PropertyName string
    33  
    34  	ConsistencyLevel *string
    35  	Tenant           *string
    36  
    37  	_basePath string
    38  	// avoid unkeyed usage
    39  	_ struct{}
    40  }
    41  
    42  // WithBasePath sets the base path for this url builder, only required when it's different from the
    43  // base path specified in the swagger spec.
    44  // When the value of the base path is an empty string
    45  func (o *ObjectsClassReferencesCreateURL) WithBasePath(bp string) *ObjectsClassReferencesCreateURL {
    46  	o.SetBasePath(bp)
    47  	return o
    48  }
    49  
    50  // SetBasePath sets the base path for this url builder, only required when it's different from the
    51  // base path specified in the swagger spec.
    52  // When the value of the base path is an empty string
    53  func (o *ObjectsClassReferencesCreateURL) SetBasePath(bp string) {
    54  	o._basePath = bp
    55  }
    56  
    57  // Build a url path and query string
    58  func (o *ObjectsClassReferencesCreateURL) Build() (*url.URL, error) {
    59  	var _result url.URL
    60  
    61  	var _path = "/objects/{className}/{id}/references/{propertyName}"
    62  
    63  	className := o.ClassName
    64  	if className != "" {
    65  		_path = strings.Replace(_path, "{className}", className, -1)
    66  	} else {
    67  		return nil, errors.New("className is required on ObjectsClassReferencesCreateURL")
    68  	}
    69  
    70  	id := o.ID.String()
    71  	if id != "" {
    72  		_path = strings.Replace(_path, "{id}", id, -1)
    73  	} else {
    74  		return nil, errors.New("id is required on ObjectsClassReferencesCreateURL")
    75  	}
    76  
    77  	propertyName := o.PropertyName
    78  	if propertyName != "" {
    79  		_path = strings.Replace(_path, "{propertyName}", propertyName, -1)
    80  	} else {
    81  		return nil, errors.New("propertyName is required on ObjectsClassReferencesCreateURL")
    82  	}
    83  
    84  	_basePath := o._basePath
    85  	if _basePath == "" {
    86  		_basePath = "/v1"
    87  	}
    88  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    89  
    90  	qs := make(url.Values)
    91  
    92  	var consistencyLevelQ string
    93  	if o.ConsistencyLevel != nil {
    94  		consistencyLevelQ = *o.ConsistencyLevel
    95  	}
    96  	if consistencyLevelQ != "" {
    97  		qs.Set("consistency_level", consistencyLevelQ)
    98  	}
    99  
   100  	var tenantQ string
   101  	if o.Tenant != nil {
   102  		tenantQ = *o.Tenant
   103  	}
   104  	if tenantQ != "" {
   105  		qs.Set("tenant", tenantQ)
   106  	}
   107  
   108  	_result.RawQuery = qs.Encode()
   109  
   110  	return &_result, nil
   111  }
   112  
   113  // Must is a helper function to panic when the url builder returns an error
   114  func (o *ObjectsClassReferencesCreateURL) Must(u *url.URL, err error) *url.URL {
   115  	if err != nil {
   116  		panic(err)
   117  	}
   118  	if u == nil {
   119  		panic("url can't be nil")
   120  	}
   121  	return u
   122  }
   123  
   124  // String returns the string representation of the path with query string
   125  func (o *ObjectsClassReferencesCreateURL) String() string {
   126  	return o.Must(o.Build()).String()
   127  }
   128  
   129  // BuildFull builds a full url with scheme, host, path and query string
   130  func (o *ObjectsClassReferencesCreateURL) BuildFull(scheme, host string) (*url.URL, error) {
   131  	if scheme == "" {
   132  		return nil, errors.New("scheme is required for a full url on ObjectsClassReferencesCreateURL")
   133  	}
   134  	if host == "" {
   135  		return nil, errors.New("host is required for a full url on ObjectsClassReferencesCreateURL")
   136  	}
   137  
   138  	base, err := o.Build()
   139  	if err != nil {
   140  		return nil, err
   141  	}
   142  
   143  	base.Scheme = scheme
   144  	base.Host = host
   145  	return base, nil
   146  }
   147  
   148  // StringFull returns the string representation of a complete url
   149  func (o *ObjectsClassReferencesCreateURL) StringFull(scheme, host string) string {
   150  	return o.Must(o.BuildFull(scheme, host)).String()
   151  }