...

Source file src/github.com/sigstore/rekor/pkg/generated/client/rekor_client.go

Documentation: github.com/sigstore/rekor/pkg/generated/client

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

View as plain text