...

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

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

     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 tlog
    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  	"github.com/go-openapi/strfmt"
    27  )
    28  
    29  // New creates a new tlog API client.
    30  func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
    31  	return &Client{transport: transport, formats: formats}
    32  }
    33  
    34  /*
    35  Client for tlog API
    36  */
    37  type Client struct {
    38  	transport runtime.ClientTransport
    39  	formats   strfmt.Registry
    40  }
    41  
    42  // ClientOption is the option for Client methods
    43  type ClientOption func(*runtime.ClientOperation)
    44  
    45  // ClientService is the interface for Client methods
    46  type ClientService interface {
    47  	GetLogInfo(params *GetLogInfoParams, opts ...ClientOption) (*GetLogInfoOK, error)
    48  
    49  	GetLogProof(params *GetLogProofParams, opts ...ClientOption) (*GetLogProofOK, error)
    50  
    51  	SetTransport(transport runtime.ClientTransport)
    52  }
    53  
    54  /*
    55  GetLogInfo gets information about the current state of the transparency log
    56  
    57  Returns the current root hash and size of the merkle tree used to store the log entries.
    58  */
    59  func (a *Client) GetLogInfo(params *GetLogInfoParams, opts ...ClientOption) (*GetLogInfoOK, error) {
    60  	// TODO: Validate the params before sending
    61  	if params == nil {
    62  		params = NewGetLogInfoParams()
    63  	}
    64  	op := &runtime.ClientOperation{
    65  		ID:                 "getLogInfo",
    66  		Method:             "GET",
    67  		PathPattern:        "/api/v1/log",
    68  		ProducesMediaTypes: []string{"application/json"},
    69  		ConsumesMediaTypes: []string{"application/json"},
    70  		Schemes:            []string{"http"},
    71  		Params:             params,
    72  		Reader:             &GetLogInfoReader{formats: a.formats},
    73  		Context:            params.Context,
    74  		Client:             params.HTTPClient,
    75  	}
    76  	for _, opt := range opts {
    77  		opt(op)
    78  	}
    79  
    80  	result, err := a.transport.Submit(op)
    81  	if err != nil {
    82  		return nil, err
    83  	}
    84  	success, ok := result.(*GetLogInfoOK)
    85  	if ok {
    86  		return success, nil
    87  	}
    88  	// unexpected success response
    89  	unexpectedSuccess := result.(*GetLogInfoDefault)
    90  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
    91  }
    92  
    93  /*
    94  GetLogProof gets information required to generate a consistency proof for the transparency log
    95  
    96  Returns a list of hashes for specified tree sizes that can be used to confirm the consistency of the transparency log
    97  */
    98  func (a *Client) GetLogProof(params *GetLogProofParams, opts ...ClientOption) (*GetLogProofOK, error) {
    99  	// TODO: Validate the params before sending
   100  	if params == nil {
   101  		params = NewGetLogProofParams()
   102  	}
   103  	op := &runtime.ClientOperation{
   104  		ID:                 "getLogProof",
   105  		Method:             "GET",
   106  		PathPattern:        "/api/v1/log/proof",
   107  		ProducesMediaTypes: []string{"application/json"},
   108  		ConsumesMediaTypes: []string{"application/json"},
   109  		Schemes:            []string{"http"},
   110  		Params:             params,
   111  		Reader:             &GetLogProofReader{formats: a.formats},
   112  		Context:            params.Context,
   113  		Client:             params.HTTPClient,
   114  	}
   115  	for _, opt := range opts {
   116  		opt(op)
   117  	}
   118  
   119  	result, err := a.transport.Submit(op)
   120  	if err != nil {
   121  		return nil, err
   122  	}
   123  	success, ok := result.(*GetLogProofOK)
   124  	if ok {
   125  		return success, nil
   126  	}
   127  	// unexpected success response
   128  	unexpectedSuccess := result.(*GetLogProofDefault)
   129  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
   130  }
   131  
   132  // SetTransport changes the transport on the client
   133  func (a *Client) SetTransport(transport runtime.ClientTransport) {
   134  	a.transport = transport
   135  }
   136  

View as plain text