...

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

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

     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 timestamp
    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  	"io"
    25  
    26  	"github.com/go-openapi/runtime"
    27  	"github.com/go-openapi/strfmt"
    28  )
    29  
    30  // New creates a new timestamp API client.
    31  func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
    32  	return &Client{transport: transport, formats: formats}
    33  }
    34  
    35  /*
    36  Client for timestamp API
    37  */
    38  type Client struct {
    39  	transport runtime.ClientTransport
    40  	formats   strfmt.Registry
    41  }
    42  
    43  // ClientOption is the option for Client methods
    44  type ClientOption func(*runtime.ClientOperation)
    45  
    46  // ClientService is the interface for Client methods
    47  type ClientService interface {
    48  	GetTimestampCertChain(params *GetTimestampCertChainParams, opts ...ClientOption) (*GetTimestampCertChainOK, error)
    49  
    50  	GetTimestampResponse(params *GetTimestampResponseParams, writer io.Writer, opts ...ClientOption) (*GetTimestampResponseCreated, error)
    51  
    52  	SetTransport(transport runtime.ClientTransport)
    53  }
    54  
    55  /*
    56  GetTimestampCertChain retrieves the certificate chain for timestamping that can be used to validate trusted timestamps
    57  
    58  Returns the certificate chain for timestamping that can be used to validate trusted timestamps
    59  */
    60  func (a *Client) GetTimestampCertChain(params *GetTimestampCertChainParams, opts ...ClientOption) (*GetTimestampCertChainOK, error) {
    61  	// TODO: Validate the params before sending
    62  	if params == nil {
    63  		params = NewGetTimestampCertChainParams()
    64  	}
    65  	op := &runtime.ClientOperation{
    66  		ID:                 "getTimestampCertChain",
    67  		Method:             "GET",
    68  		PathPattern:        "/api/v1/timestamp/certchain",
    69  		ProducesMediaTypes: []string{"application/pem-certificate-chain"},
    70  		ConsumesMediaTypes: []string{"application/json"},
    71  		Schemes:            []string{"http"},
    72  		Params:             params,
    73  		Reader:             &GetTimestampCertChainReader{formats: a.formats},
    74  		Context:            params.Context,
    75  		Client:             params.HTTPClient,
    76  	}
    77  	for _, opt := range opts {
    78  		opt(op)
    79  	}
    80  
    81  	result, err := a.transport.Submit(op)
    82  	if err != nil {
    83  		return nil, err
    84  	}
    85  	success, ok := result.(*GetTimestampCertChainOK)
    86  	if ok {
    87  		return success, nil
    88  	}
    89  	// unexpected success response
    90  	unexpectedSuccess := result.(*GetTimestampCertChainDefault)
    91  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
    92  }
    93  
    94  /*
    95  GetTimestampResponse generates a new timestamp response and creates a new log entry for the timestamp in the transparency log
    96  */
    97  func (a *Client) GetTimestampResponse(params *GetTimestampResponseParams, writer io.Writer, opts ...ClientOption) (*GetTimestampResponseCreated, error) {
    98  	// TODO: Validate the params before sending
    99  	if params == nil {
   100  		params = NewGetTimestampResponseParams()
   101  	}
   102  	op := &runtime.ClientOperation{
   103  		ID:                 "getTimestampResponse",
   104  		Method:             "POST",
   105  		PathPattern:        "/api/v1/timestamp",
   106  		ProducesMediaTypes: []string{"application/timestamp-reply"},
   107  		ConsumesMediaTypes: []string{"application/json", "application/timestamp-query"},
   108  		Schemes:            []string{"http"},
   109  		Params:             params,
   110  		Reader:             &GetTimestampResponseReader{formats: a.formats, writer: writer},
   111  		Context:            params.Context,
   112  		Client:             params.HTTPClient,
   113  	}
   114  	for _, opt := range opts {
   115  		opt(op)
   116  	}
   117  
   118  	result, err := a.transport.Submit(op)
   119  	if err != nil {
   120  		return nil, err
   121  	}
   122  	success, ok := result.(*GetTimestampResponseCreated)
   123  	if ok {
   124  		return success, nil
   125  	}
   126  	// unexpected success response
   127  	unexpectedSuccess := result.(*GetTimestampResponseDefault)
   128  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
   129  }
   130  
   131  // SetTransport changes the transport on the client
   132  func (a *Client) SetTransport(transport runtime.ClientTransport) {
   133  	a.transport = transport
   134  }
   135  

View as plain text