refactor: expose generated code and client business logic to share with Kapacitor (#103)
* refactor: take clients out of internal * refactor: move stdio to pkg * Move internal/api to api * refactor: final changes for Kapacitor to access shared functionality * chore: regenerate mocks * fix: bad automated refactor * chore: extra formatting not caught by make fmt
This commit is contained in:
327
api/api_write.gen.go
Normal file
327
api/api_write.gen.go
Normal file
@ -0,0 +1,327 @@
|
||||
/*
|
||||
* Subset of Influx API covered by Influx CLI
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* API version: 2.0.0
|
||||
*/
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
_gzip "compress/gzip"
|
||||
_context "context"
|
||||
_io "io"
|
||||
_ioutil "io/ioutil"
|
||||
_nethttp "net/http"
|
||||
_neturl "net/url"
|
||||
)
|
||||
|
||||
// Linger please
|
||||
var (
|
||||
_ _context.Context
|
||||
)
|
||||
|
||||
type WriteApi interface {
|
||||
|
||||
/*
|
||||
* PostWrite Write time series data into InfluxDB
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @return ApiPostWriteRequest
|
||||
*/
|
||||
PostWrite(ctx _context.Context) ApiPostWriteRequest
|
||||
|
||||
/*
|
||||
* PostWriteExecute executes the request
|
||||
*/
|
||||
PostWriteExecute(r ApiPostWriteRequest) error
|
||||
}
|
||||
|
||||
// writeApiGzipReadCloser supports streaming gzip response-bodies directly from the server.
|
||||
type writeApiGzipReadCloser struct {
|
||||
underlying _io.ReadCloser
|
||||
gzip _io.ReadCloser
|
||||
}
|
||||
|
||||
func (gzrc *writeApiGzipReadCloser) Read(p []byte) (int, error) {
|
||||
return gzrc.gzip.Read(p)
|
||||
}
|
||||
func (gzrc *writeApiGzipReadCloser) Close() error {
|
||||
if err := gzrc.gzip.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
return gzrc.underlying.Close()
|
||||
}
|
||||
|
||||
// WriteApiService WriteApi service
|
||||
type WriteApiService service
|
||||
|
||||
type ApiPostWriteRequest struct {
|
||||
ctx _context.Context
|
||||
ApiService WriteApi
|
||||
org *string
|
||||
bucket *string
|
||||
body []byte
|
||||
zapTraceSpan *string
|
||||
contentEncoding *string
|
||||
contentType *string
|
||||
contentLength *int32
|
||||
accept *string
|
||||
orgID *string
|
||||
precision *WritePrecision
|
||||
}
|
||||
|
||||
func (r ApiPostWriteRequest) Org(org string) ApiPostWriteRequest {
|
||||
r.org = &org
|
||||
return r
|
||||
}
|
||||
func (r ApiPostWriteRequest) GetOrg() *string {
|
||||
return r.org
|
||||
}
|
||||
|
||||
func (r ApiPostWriteRequest) Bucket(bucket string) ApiPostWriteRequest {
|
||||
r.bucket = &bucket
|
||||
return r
|
||||
}
|
||||
func (r ApiPostWriteRequest) GetBucket() *string {
|
||||
return r.bucket
|
||||
}
|
||||
|
||||
func (r ApiPostWriteRequest) Body(body []byte) ApiPostWriteRequest {
|
||||
r.body = body
|
||||
return r
|
||||
}
|
||||
func (r ApiPostWriteRequest) GetBody() []byte {
|
||||
return r.body
|
||||
}
|
||||
|
||||
func (r ApiPostWriteRequest) ZapTraceSpan(zapTraceSpan string) ApiPostWriteRequest {
|
||||
r.zapTraceSpan = &zapTraceSpan
|
||||
return r
|
||||
}
|
||||
func (r ApiPostWriteRequest) GetZapTraceSpan() *string {
|
||||
return r.zapTraceSpan
|
||||
}
|
||||
|
||||
func (r ApiPostWriteRequest) ContentEncoding(contentEncoding string) ApiPostWriteRequest {
|
||||
r.contentEncoding = &contentEncoding
|
||||
return r
|
||||
}
|
||||
func (r ApiPostWriteRequest) GetContentEncoding() *string {
|
||||
return r.contentEncoding
|
||||
}
|
||||
|
||||
func (r ApiPostWriteRequest) ContentType(contentType string) ApiPostWriteRequest {
|
||||
r.contentType = &contentType
|
||||
return r
|
||||
}
|
||||
func (r ApiPostWriteRequest) GetContentType() *string {
|
||||
return r.contentType
|
||||
}
|
||||
|
||||
func (r ApiPostWriteRequest) ContentLength(contentLength int32) ApiPostWriteRequest {
|
||||
r.contentLength = &contentLength
|
||||
return r
|
||||
}
|
||||
func (r ApiPostWriteRequest) GetContentLength() *int32 {
|
||||
return r.contentLength
|
||||
}
|
||||
|
||||
func (r ApiPostWriteRequest) Accept(accept string) ApiPostWriteRequest {
|
||||
r.accept = &accept
|
||||
return r
|
||||
}
|
||||
func (r ApiPostWriteRequest) GetAccept() *string {
|
||||
return r.accept
|
||||
}
|
||||
|
||||
func (r ApiPostWriteRequest) OrgID(orgID string) ApiPostWriteRequest {
|
||||
r.orgID = &orgID
|
||||
return r
|
||||
}
|
||||
func (r ApiPostWriteRequest) GetOrgID() *string {
|
||||
return r.orgID
|
||||
}
|
||||
|
||||
func (r ApiPostWriteRequest) Precision(precision WritePrecision) ApiPostWriteRequest {
|
||||
r.precision = &precision
|
||||
return r
|
||||
}
|
||||
func (r ApiPostWriteRequest) GetPrecision() *WritePrecision {
|
||||
return r.precision
|
||||
}
|
||||
|
||||
func (r ApiPostWriteRequest) Execute() error {
|
||||
return r.ApiService.PostWriteExecute(r)
|
||||
}
|
||||
|
||||
/*
|
||||
* PostWrite Write time series data into InfluxDB
|
||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
* @return ApiPostWriteRequest
|
||||
*/
|
||||
func (a *WriteApiService) PostWrite(ctx _context.Context) ApiPostWriteRequest {
|
||||
return ApiPostWriteRequest{
|
||||
ApiService: a,
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute executes the request
|
||||
*/
|
||||
func (a *WriteApiService) PostWriteExecute(r ApiPostWriteRequest) error {
|
||||
var (
|
||||
localVarHTTPMethod = _nethttp.MethodPost
|
||||
localVarPostBody interface{}
|
||||
localVarFormFileName string
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WriteApiService.PostWrite")
|
||||
if err != nil {
|
||||
return GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
||||
localVarPath := localBasePath + "/write"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := _neturl.Values{}
|
||||
localVarFormParams := _neturl.Values{}
|
||||
if r.org == nil {
|
||||
return reportError("org is required and must be specified")
|
||||
}
|
||||
if r.bucket == nil {
|
||||
return reportError("bucket is required and must be specified")
|
||||
}
|
||||
if r.body == nil {
|
||||
return reportError("body is required and must be specified")
|
||||
}
|
||||
|
||||
localVarQueryParams.Add("org", parameterToString(*r.org, ""))
|
||||
if r.orgID != nil {
|
||||
localVarQueryParams.Add("orgID", parameterToString(*r.orgID, ""))
|
||||
}
|
||||
localVarQueryParams.Add("bucket", parameterToString(*r.bucket, ""))
|
||||
if r.precision != nil {
|
||||
localVarQueryParams.Add("precision", parameterToString(*r.precision, ""))
|
||||
}
|
||||
// to determine the Content-Type header
|
||||
localVarHTTPContentTypes := []string{"text/plain"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
||||
if localVarHTTPContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHTTPHeaderAccepts := []string{"application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
||||
if localVarHTTPHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
||||
}
|
||||
if r.zapTraceSpan != nil {
|
||||
localVarHeaderParams["Zap-Trace-Span"] = parameterToString(*r.zapTraceSpan, "")
|
||||
}
|
||||
if r.contentEncoding != nil {
|
||||
localVarHeaderParams["Content-Encoding"] = parameterToString(*r.contentEncoding, "")
|
||||
}
|
||||
if r.contentType != nil {
|
||||
localVarHeaderParams["Content-Type"] = parameterToString(*r.contentType, "")
|
||||
}
|
||||
if r.contentLength != nil {
|
||||
localVarHeaderParams["Content-Length"] = parameterToString(*r.contentLength, "")
|
||||
}
|
||||
if r.accept != nil {
|
||||
localVarHeaderParams["Accept"] = parameterToString(*r.accept, "")
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = r.body
|
||||
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
localVarHTTPResponse, err := a.client.callAPI(req)
|
||||
if err != nil || localVarHTTPResponse == nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var body _io.ReadCloser = localVarHTTPResponse.Body
|
||||
if localVarHTTPResponse.Header.Get("Content-Encoding") == "gzip" {
|
||||
gzr, err := _gzip.NewReader(body)
|
||||
if err != nil {
|
||||
body.Close()
|
||||
return err
|
||||
}
|
||||
body = &writeApiGzipReadCloser{underlying: body, gzip: gzr}
|
||||
}
|
||||
|
||||
if localVarHTTPResponse.StatusCode >= 300 {
|
||||
localVarBody, err := _ioutil.ReadAll(body)
|
||||
body.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
newErr := GenericOpenAPIError{
|
||||
body: localVarBody,
|
||||
error: localVarHTTPResponse.Status,
|
||||
}
|
||||
if localVarHTTPResponse.StatusCode == 400 {
|
||||
var v LineProtocolError
|
||||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return newErr
|
||||
}
|
||||
newErr.model = &v
|
||||
return newErr
|
||||
}
|
||||
if localVarHTTPResponse.StatusCode == 401 {
|
||||
var v Error
|
||||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return newErr
|
||||
}
|
||||
newErr.model = &v
|
||||
return newErr
|
||||
}
|
||||
if localVarHTTPResponse.StatusCode == 403 {
|
||||
var v Error
|
||||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return newErr
|
||||
}
|
||||
newErr.model = &v
|
||||
return newErr
|
||||
}
|
||||
if localVarHTTPResponse.StatusCode == 413 {
|
||||
var v LineProtocolLengthError
|
||||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return newErr
|
||||
}
|
||||
newErr.model = &v
|
||||
return newErr
|
||||
}
|
||||
var v Error
|
||||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return newErr
|
||||
}
|
||||
newErr.model = &v
|
||||
return newErr
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user