github.com/weaviate/weaviate@v1.24.6/adapters/handlers/rest/operations/graphql/graphql_batch_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 graphql
    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  )
    24  
    25  // GraphqlBatchURL generates an URL for the graphql batch operation
    26  type GraphqlBatchURL struct {
    27  	_basePath string
    28  }
    29  
    30  // WithBasePath sets the base path for this url builder, only required when it's different from the
    31  // base path specified in the swagger spec.
    32  // When the value of the base path is an empty string
    33  func (o *GraphqlBatchURL) WithBasePath(bp string) *GraphqlBatchURL {
    34  	o.SetBasePath(bp)
    35  	return o
    36  }
    37  
    38  // SetBasePath sets the base path for this url builder, only required when it's different from the
    39  // base path specified in the swagger spec.
    40  // When the value of the base path is an empty string
    41  func (o *GraphqlBatchURL) SetBasePath(bp string) {
    42  	o._basePath = bp
    43  }
    44  
    45  // Build a url path and query string
    46  func (o *GraphqlBatchURL) Build() (*url.URL, error) {
    47  	var _result url.URL
    48  
    49  	var _path = "/graphql/batch"
    50  
    51  	_basePath := o._basePath
    52  	if _basePath == "" {
    53  		_basePath = "/v1"
    54  	}
    55  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    56  
    57  	return &_result, nil
    58  }
    59  
    60  // Must is a helper function to panic when the url builder returns an error
    61  func (o *GraphqlBatchURL) Must(u *url.URL, err error) *url.URL {
    62  	if err != nil {
    63  		panic(err)
    64  	}
    65  	if u == nil {
    66  		panic("url can't be nil")
    67  	}
    68  	return u
    69  }
    70  
    71  // String returns the string representation of the path with query string
    72  func (o *GraphqlBatchURL) String() string {
    73  	return o.Must(o.Build()).String()
    74  }
    75  
    76  // BuildFull builds a full url with scheme, host, path and query string
    77  func (o *GraphqlBatchURL) BuildFull(scheme, host string) (*url.URL, error) {
    78  	if scheme == "" {
    79  		return nil, errors.New("scheme is required for a full url on GraphqlBatchURL")
    80  	}
    81  	if host == "" {
    82  		return nil, errors.New("host is required for a full url on GraphqlBatchURL")
    83  	}
    84  
    85  	base, err := o.Build()
    86  	if err != nil {
    87  		return nil, err
    88  	}
    89  
    90  	base.Scheme = scheme
    91  	base.Host = host
    92  	return base, nil
    93  }
    94  
    95  // StringFull returns the string representation of a complete url
    96  func (o *GraphqlBatchURL) StringFull(scheme, host string) string {
    97  	return o.Must(o.BuildFull(scheme, host)).String()
    98  }