github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-billing/preview/2020-11-05/client/cloud_billing_client.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package client
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"github.com/go-openapi/runtime"
    10  	httptransport "github.com/go-openapi/runtime/client"
    11  	"github.com/go-openapi/strfmt"
    12  
    13  	"github.com/hashicorp/hcp-sdk-go/clients/cloud-billing/preview/2020-11-05/client/billing_account_service"
    14  	"github.com/hashicorp/hcp-sdk-go/clients/cloud-billing/preview/2020-11-05/client/f_c_p_management_service"
    15  	"github.com/hashicorp/hcp-sdk-go/clients/cloud-billing/preview/2020-11-05/client/invoice_service"
    16  	"github.com/hashicorp/hcp-sdk-go/clients/cloud-billing/preview/2020-11-05/client/product_service"
    17  	"github.com/hashicorp/hcp-sdk-go/clients/cloud-billing/preview/2020-11-05/client/statement_service"
    18  )
    19  
    20  // Default cloud billing HTTP client.
    21  var Default = NewHTTPClient(nil)
    22  
    23  const (
    24  	// DefaultHost is the default Host
    25  	// found in Meta (info) section of spec file
    26  	DefaultHost string = "api.cloud.hashicorp.com"
    27  	// DefaultBasePath is the default BasePath
    28  	// found in Meta (info) section of spec file
    29  	DefaultBasePath string = "/"
    30  )
    31  
    32  // DefaultSchemes are the default schemes found in Meta (info) section of spec file
    33  var DefaultSchemes = []string{"http"}
    34  
    35  // NewHTTPClient creates a new cloud billing HTTP client.
    36  func NewHTTPClient(formats strfmt.Registry) *CloudBilling {
    37  	return NewHTTPClientWithConfig(formats, nil)
    38  }
    39  
    40  // NewHTTPClientWithConfig creates a new cloud billing HTTP client,
    41  // using a customizable transport config.
    42  func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *CloudBilling {
    43  	// ensure nullable parameters have default
    44  	if cfg == nil {
    45  		cfg = DefaultTransportConfig()
    46  	}
    47  
    48  	// create transport and client
    49  	transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
    50  	return New(transport, formats)
    51  }
    52  
    53  // New creates a new cloud billing client
    54  func New(transport runtime.ClientTransport, formats strfmt.Registry) *CloudBilling {
    55  	// ensure nullable parameters have default
    56  	if formats == nil {
    57  		formats = strfmt.Default
    58  	}
    59  
    60  	cli := new(CloudBilling)
    61  	cli.Transport = transport
    62  	cli.BillingAccountService = billing_account_service.New(transport, formats)
    63  	cli.FcpManagementService = f_c_p_management_service.New(transport, formats)
    64  	cli.InvoiceService = invoice_service.New(transport, formats)
    65  	cli.ProductService = product_service.New(transport, formats)
    66  	cli.StatementService = statement_service.New(transport, formats)
    67  	return cli
    68  }
    69  
    70  // DefaultTransportConfig creates a TransportConfig with the
    71  // default settings taken from the meta section of the spec file.
    72  func DefaultTransportConfig() *TransportConfig {
    73  	return &TransportConfig{
    74  		Host:     DefaultHost,
    75  		BasePath: DefaultBasePath,
    76  		Schemes:  DefaultSchemes,
    77  	}
    78  }
    79  
    80  // TransportConfig contains the transport related info,
    81  // found in the meta section of the spec file.
    82  type TransportConfig struct {
    83  	Host     string
    84  	BasePath string
    85  	Schemes  []string
    86  }
    87  
    88  // WithHost overrides the default host,
    89  // provided by the meta section of the spec file.
    90  func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
    91  	cfg.Host = host
    92  	return cfg
    93  }
    94  
    95  // WithBasePath overrides the default basePath,
    96  // provided by the meta section of the spec file.
    97  func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
    98  	cfg.BasePath = basePath
    99  	return cfg
   100  }
   101  
   102  // WithSchemes overrides the default schemes,
   103  // provided by the meta section of the spec file.
   104  func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
   105  	cfg.Schemes = schemes
   106  	return cfg
   107  }
   108  
   109  // CloudBilling is a client for cloud billing
   110  type CloudBilling struct {
   111  	BillingAccountService billing_account_service.ClientService
   112  
   113  	FcpManagementService f_c_p_management_service.ClientService
   114  
   115  	InvoiceService invoice_service.ClientService
   116  
   117  	ProductService product_service.ClientService
   118  
   119  	StatementService statement_service.ClientService
   120  
   121  	Transport runtime.ClientTransport
   122  }
   123  
   124  // SetTransport changes the transport on the client and all its subresources
   125  func (c *CloudBilling) SetTransport(transport runtime.ClientTransport) {
   126  	c.Transport = transport
   127  	c.BillingAccountService.SetTransport(transport)
   128  	c.FcpManagementService.SetTransport(transport)
   129  	c.InvoiceService.SetTransport(transport)
   130  	c.ProductService.SetTransport(transport)
   131  	c.StatementService.SetTransport(transport)
   132  }