...

Source file src/github.com/sigstore/timestamp-authority/pkg/generated/client/timestamp_authority_client.go

Documentation: github.com/sigstore/timestamp-authority/pkg/generated/client

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright 2022 The Sigstore Authors.
     4  //
     5  // Licensed under the Apache License, Version 2.0 (the "License");
     6  // you may not use this file except in compliance with the License.
     7  // You may obtain a copy of the License at
     8  //
     9  //     http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing, software
    12  // distributed under the License is distributed on an "AS IS" BASIS,
    13  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  // See the License for the specific language governing permissions and
    15  // limitations under the License.
    16  //
    17  
    18  package client
    19  
    20  // This file was generated by the swagger tool.
    21  // Editing this file might prove futile when you re-run the swagger generate command
    22  
    23  import (
    24  	"github.com/go-openapi/runtime"
    25  	httptransport "github.com/go-openapi/runtime/client"
    26  	"github.com/go-openapi/strfmt"
    27  
    28  	"github.com/sigstore/timestamp-authority/pkg/generated/client/timestamp"
    29  )
    30  
    31  // Default timestamp authority HTTP client.
    32  var Default = NewHTTPClient(nil)
    33  
    34  const (
    35  	// DefaultHost is the default Host
    36  	// found in Meta (info) section of spec file
    37  	DefaultHost string = "timestamp.sigstore.dev"
    38  	// DefaultBasePath is the default BasePath
    39  	// found in Meta (info) section of spec file
    40  	DefaultBasePath string = "/"
    41  )
    42  
    43  // DefaultSchemes are the default schemes found in Meta (info) section of spec file
    44  var DefaultSchemes = []string{"http"}
    45  
    46  // NewHTTPClient creates a new timestamp authority HTTP client.
    47  func NewHTTPClient(formats strfmt.Registry) *TimestampAuthority {
    48  	return NewHTTPClientWithConfig(formats, nil)
    49  }
    50  
    51  // NewHTTPClientWithConfig creates a new timestamp authority HTTP client,
    52  // using a customizable transport config.
    53  func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *TimestampAuthority {
    54  	// ensure nullable parameters have default
    55  	if cfg == nil {
    56  		cfg = DefaultTransportConfig()
    57  	}
    58  
    59  	// create transport and client
    60  	transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
    61  	return New(transport, formats)
    62  }
    63  
    64  // New creates a new timestamp authority client
    65  func New(transport runtime.ClientTransport, formats strfmt.Registry) *TimestampAuthority {
    66  	// ensure nullable parameters have default
    67  	if formats == nil {
    68  		formats = strfmt.Default
    69  	}
    70  
    71  	cli := new(TimestampAuthority)
    72  	cli.Transport = transport
    73  	cli.Timestamp = timestamp.New(transport, formats)
    74  	return cli
    75  }
    76  
    77  // DefaultTransportConfig creates a TransportConfig with the
    78  // default settings taken from the meta section of the spec file.
    79  func DefaultTransportConfig() *TransportConfig {
    80  	return &TransportConfig{
    81  		Host:     DefaultHost,
    82  		BasePath: DefaultBasePath,
    83  		Schemes:  DefaultSchemes,
    84  	}
    85  }
    86  
    87  // TransportConfig contains the transport related info,
    88  // found in the meta section of the spec file.
    89  type TransportConfig struct {
    90  	Host     string
    91  	BasePath string
    92  	Schemes  []string
    93  }
    94  
    95  // WithHost overrides the default host,
    96  // provided by the meta section of the spec file.
    97  func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
    98  	cfg.Host = host
    99  	return cfg
   100  }
   101  
   102  // WithBasePath overrides the default basePath,
   103  // provided by the meta section of the spec file.
   104  func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
   105  	cfg.BasePath = basePath
   106  	return cfg
   107  }
   108  
   109  // WithSchemes overrides the default schemes,
   110  // provided by the meta section of the spec file.
   111  func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
   112  	cfg.Schemes = schemes
   113  	return cfg
   114  }
   115  
   116  // TimestampAuthority is a client for timestamp authority
   117  type TimestampAuthority struct {
   118  	Timestamp timestamp.ClientService
   119  
   120  	Transport runtime.ClientTransport
   121  }
   122  
   123  // SetTransport changes the transport on the client and all its subresources
   124  func (c *TimestampAuthority) SetTransport(transport runtime.ClientTransport) {
   125  	c.Transport = transport
   126  	c.Timestamp.SetTransport(transport)
   127  }
   128  

View as plain text