feat: reimplement influx telegrafs with new APIs (#120)

* feat: reimplement `influx telegrafs` with new APIs

* chore: restructure structs for later modification

* refactor: bump openapi & regenerate clients

* refactor: better error output and descriptions

Co-authored-by: Dan Moran <dmoran@influxdata.com>
This commit is contained in:
Dane Strandboge 2021-06-15 14:55:04 -05:00 committed by GitHub
parent 581daaa5ba
commit abe521add0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 2890 additions and 80 deletions

View File

@ -27,18 +27,17 @@ var (
type RestoreApi interface {
/*
* PostRestoreBucketMetadataId Create a new bucket pre-seeded with shard info from a backup.
* PostRestoreBucketMetadata Create a new bucket pre-seeded with shard info from a backup.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param bucketID The bucket ID.
* @return ApiPostRestoreBucketMetadataIdRequest
* @return ApiPostRestoreBucketMetadataRequest
*/
PostRestoreBucketMetadataId(ctx _context.Context, bucketID string) ApiPostRestoreBucketMetadataIdRequest
PostRestoreBucketMetadata(ctx _context.Context) ApiPostRestoreBucketMetadataRequest
/*
* PostRestoreBucketMetadataIdExecute executes the request
* @return []BucketShardMapping
* PostRestoreBucketMetadataExecute executes the request
* @return RestoredBucketMappings
*/
PostRestoreBucketMetadataIdExecute(r ApiPostRestoreBucketMetadataIdRequest) ([]BucketShardMapping, error)
PostRestoreBucketMetadataExecute(r ApiPostRestoreBucketMetadataRequest) (RestoredBucketMappings, error)
/*
* PostRestoreKV Overwrite the embedded KV store on the server with a backed-up snapshot.
@ -81,77 +80,65 @@ type RestoreApi interface {
// RestoreApiService RestoreApi service
type RestoreApiService service
type ApiPostRestoreBucketMetadataIdRequest struct {
type ApiPostRestoreBucketMetadataRequest struct {
ctx _context.Context
ApiService RestoreApi
bucketID string
bucketMetadataManifest *BucketMetadataManifest
zapTraceSpan *string
}
func (r ApiPostRestoreBucketMetadataIdRequest) BucketID(bucketID string) ApiPostRestoreBucketMetadataIdRequest {
r.bucketID = bucketID
return r
}
func (r ApiPostRestoreBucketMetadataIdRequest) GetBucketID() string {
return r.bucketID
}
func (r ApiPostRestoreBucketMetadataIdRequest) BucketMetadataManifest(bucketMetadataManifest BucketMetadataManifest) ApiPostRestoreBucketMetadataIdRequest {
func (r ApiPostRestoreBucketMetadataRequest) BucketMetadataManifest(bucketMetadataManifest BucketMetadataManifest) ApiPostRestoreBucketMetadataRequest {
r.bucketMetadataManifest = &bucketMetadataManifest
return r
}
func (r ApiPostRestoreBucketMetadataIdRequest) GetBucketMetadataManifest() *BucketMetadataManifest {
func (r ApiPostRestoreBucketMetadataRequest) GetBucketMetadataManifest() *BucketMetadataManifest {
return r.bucketMetadataManifest
}
func (r ApiPostRestoreBucketMetadataIdRequest) ZapTraceSpan(zapTraceSpan string) ApiPostRestoreBucketMetadataIdRequest {
func (r ApiPostRestoreBucketMetadataRequest) ZapTraceSpan(zapTraceSpan string) ApiPostRestoreBucketMetadataRequest {
r.zapTraceSpan = &zapTraceSpan
return r
}
func (r ApiPostRestoreBucketMetadataIdRequest) GetZapTraceSpan() *string {
func (r ApiPostRestoreBucketMetadataRequest) GetZapTraceSpan() *string {
return r.zapTraceSpan
}
func (r ApiPostRestoreBucketMetadataIdRequest) Execute() ([]BucketShardMapping, error) {
return r.ApiService.PostRestoreBucketMetadataIdExecute(r)
func (r ApiPostRestoreBucketMetadataRequest) Execute() (RestoredBucketMappings, error) {
return r.ApiService.PostRestoreBucketMetadataExecute(r)
}
/*
* PostRestoreBucketMetadataId Create a new bucket pre-seeded with shard info from a backup.
* PostRestoreBucketMetadata Create a new bucket pre-seeded with shard info from a backup.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param bucketID The bucket ID.
* @return ApiPostRestoreBucketMetadataIdRequest
* @return ApiPostRestoreBucketMetadataRequest
*/
func (a *RestoreApiService) PostRestoreBucketMetadataId(ctx _context.Context, bucketID string) ApiPostRestoreBucketMetadataIdRequest {
return ApiPostRestoreBucketMetadataIdRequest{
func (a *RestoreApiService) PostRestoreBucketMetadata(ctx _context.Context) ApiPostRestoreBucketMetadataRequest {
return ApiPostRestoreBucketMetadataRequest{
ApiService: a,
ctx: ctx,
bucketID: bucketID,
}
}
/*
* Execute executes the request
* @return []BucketShardMapping
* @return RestoredBucketMappings
*/
func (a *RestoreApiService) PostRestoreBucketMetadataIdExecute(r ApiPostRestoreBucketMetadataIdRequest) ([]BucketShardMapping, error) {
func (a *RestoreApiService) PostRestoreBucketMetadataExecute(r ApiPostRestoreBucketMetadataRequest) (RestoredBucketMappings, error) {
var (
localVarHTTPMethod = _nethttp.MethodPost
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue []BucketShardMapping
localVarReturnValue RestoredBucketMappings
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RestoreApiService.PostRestoreBucketMetadataId")
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RestoreApiService.PostRestoreBucketMetadata")
if err != nil {
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/restore/bucket-metadata/{bucketID}"
localVarPath = strings.Replace(localVarPath, "{"+"bucketID"+"}", _neturl.PathEscape(parameterToString(r.bucketID, "")), -1)
localVarPath := localBasePath + "/restore/bucket-metadata"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
@ -245,6 +232,7 @@ type ApiPostRestoreKVRequest struct {
body _io.ReadCloser
zapTraceSpan *string
contentEncoding *string
contentType *string
}
func (r ApiPostRestoreKVRequest) Body(body _io.ReadCloser) ApiPostRestoreKVRequest {
@ -271,6 +259,14 @@ func (r ApiPostRestoreKVRequest) GetContentEncoding() *string {
return r.contentEncoding
}
func (r ApiPostRestoreKVRequest) ContentType(contentType string) ApiPostRestoreKVRequest {
r.contentType = &contentType
return r
}
func (r ApiPostRestoreKVRequest) GetContentType() *string {
return r.contentType
}
func (r ApiPostRestoreKVRequest) Execute() error {
return r.ApiService.PostRestoreKVExecute(r)
}
@ -314,7 +310,7 @@ func (a *RestoreApiService) PostRestoreKVExecute(r ApiPostRestoreKVRequest) erro
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/octet-stream"}
localVarHTTPContentTypes := []string{"text/plain"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
@ -336,6 +332,9 @@ func (a *RestoreApiService) PostRestoreKVExecute(r ApiPostRestoreKVRequest) erro
if r.contentEncoding != nil {
localVarHeaderParams["Content-Encoding"] = parameterToString(*r.contentEncoding, "")
}
if r.contentType != nil {
localVarHeaderParams["Content-Type"] = parameterToString(*r.contentType, "")
}
// body params
localVarPostBody = r.body
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
@ -382,6 +381,7 @@ type ApiPostRestoreSQLRequest struct {
body _io.ReadCloser
zapTraceSpan *string
contentEncoding *string
contentType *string
}
func (r ApiPostRestoreSQLRequest) Body(body _io.ReadCloser) ApiPostRestoreSQLRequest {
@ -408,6 +408,14 @@ func (r ApiPostRestoreSQLRequest) GetContentEncoding() *string {
return r.contentEncoding
}
func (r ApiPostRestoreSQLRequest) ContentType(contentType string) ApiPostRestoreSQLRequest {
r.contentType = &contentType
return r
}
func (r ApiPostRestoreSQLRequest) GetContentType() *string {
return r.contentType
}
func (r ApiPostRestoreSQLRequest) Execute() error {
return r.ApiService.PostRestoreSQLExecute(r)
}
@ -451,7 +459,7 @@ func (a *RestoreApiService) PostRestoreSQLExecute(r ApiPostRestoreSQLRequest) er
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/octet-stream"}
localVarHTTPContentTypes := []string{"text/plain"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
@ -473,6 +481,9 @@ func (a *RestoreApiService) PostRestoreSQLExecute(r ApiPostRestoreSQLRequest) er
if r.contentEncoding != nil {
localVarHeaderParams["Content-Encoding"] = parameterToString(*r.contentEncoding, "")
}
if r.contentType != nil {
localVarHeaderParams["Content-Type"] = parameterToString(*r.contentType, "")
}
// body params
localVarPostBody = r.body
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
@ -520,6 +531,7 @@ type ApiPostRestoreShardIdRequest struct {
body _io.ReadCloser
zapTraceSpan *string
contentEncoding *string
contentType *string
}
func (r ApiPostRestoreShardIdRequest) ShardID(shardID string) ApiPostRestoreShardIdRequest {
@ -554,6 +566,14 @@ func (r ApiPostRestoreShardIdRequest) GetContentEncoding() *string {
return r.contentEncoding
}
func (r ApiPostRestoreShardIdRequest) ContentType(contentType string) ApiPostRestoreShardIdRequest {
r.contentType = &contentType
return r
}
func (r ApiPostRestoreShardIdRequest) GetContentType() *string {
return r.contentType
}
func (r ApiPostRestoreShardIdRequest) Execute() error {
return r.ApiService.PostRestoreShardIdExecute(r)
}
@ -600,7 +620,7 @@ func (a *RestoreApiService) PostRestoreShardIdExecute(r ApiPostRestoreShardIdReq
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/octet-stream"}
localVarHTTPContentTypes := []string{"text/plain"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
@ -622,6 +642,9 @@ func (a *RestoreApiService) PostRestoreShardIdExecute(r ApiPostRestoreShardIdReq
if r.contentEncoding != nil {
localVarHeaderParams["Content-Encoding"] = parameterToString(*r.contentEncoding, "")
}
if r.contentType != nil {
localVarHeaderParams["Content-Type"] = parameterToString(*r.contentType, "")
}
// body params
localVarPostBody = r.body
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)

824
api/api_telegrafs.gen.go Normal file
View File

@ -0,0 +1,824 @@
/*
* 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 (
_context "context"
_ioutil "io/ioutil"
_nethttp "net/http"
_neturl "net/url"
"strings"
)
// Linger please
var (
_ _context.Context
)
type TelegrafsApi interface {
/*
* DeleteTelegrafsID Delete a Telegraf configuration
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param telegrafID The Telegraf configuration ID.
* @return ApiDeleteTelegrafsIDRequest
*/
DeleteTelegrafsID(ctx _context.Context, telegrafID string) ApiDeleteTelegrafsIDRequest
/*
* DeleteTelegrafsIDExecute executes the request
*/
DeleteTelegrafsIDExecute(r ApiDeleteTelegrafsIDRequest) error
/*
* GetTelegrafs List all Telegraf configurations
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiGetTelegrafsRequest
*/
GetTelegrafs(ctx _context.Context) ApiGetTelegrafsRequest
/*
* GetTelegrafsExecute executes the request
* @return Telegrafs
*/
GetTelegrafsExecute(r ApiGetTelegrafsRequest) (Telegrafs, error)
/*
* GetTelegrafsID Retrieve a Telegraf configuration
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param telegrafID The Telegraf configuration ID.
* @return ApiGetTelegrafsIDRequest
*/
GetTelegrafsID(ctx _context.Context, telegrafID string) ApiGetTelegrafsIDRequest
/*
* GetTelegrafsIDExecute executes the request
* @return Telegraf
*/
GetTelegrafsIDExecute(r ApiGetTelegrafsIDRequest) (Telegraf, error)
/*
* PostTelegrafs Create a Telegraf configuration
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiPostTelegrafsRequest
*/
PostTelegrafs(ctx _context.Context) ApiPostTelegrafsRequest
/*
* PostTelegrafsExecute executes the request
* @return Telegraf
*/
PostTelegrafsExecute(r ApiPostTelegrafsRequest) (Telegraf, error)
/*
* PutTelegrafsID Update a Telegraf configuration
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param telegrafID The Telegraf config ID.
* @return ApiPutTelegrafsIDRequest
*/
PutTelegrafsID(ctx _context.Context, telegrafID string) ApiPutTelegrafsIDRequest
/*
* PutTelegrafsIDExecute executes the request
* @return Telegraf
*/
PutTelegrafsIDExecute(r ApiPutTelegrafsIDRequest) (Telegraf, error)
}
// TelegrafsApiService TelegrafsApi service
type TelegrafsApiService service
type ApiDeleteTelegrafsIDRequest struct {
ctx _context.Context
ApiService TelegrafsApi
telegrafID string
zapTraceSpan *string
}
func (r ApiDeleteTelegrafsIDRequest) TelegrafID(telegrafID string) ApiDeleteTelegrafsIDRequest {
r.telegrafID = telegrafID
return r
}
func (r ApiDeleteTelegrafsIDRequest) GetTelegrafID() string {
return r.telegrafID
}
func (r ApiDeleteTelegrafsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiDeleteTelegrafsIDRequest {
r.zapTraceSpan = &zapTraceSpan
return r
}
func (r ApiDeleteTelegrafsIDRequest) GetZapTraceSpan() *string {
return r.zapTraceSpan
}
func (r ApiDeleteTelegrafsIDRequest) Execute() error {
return r.ApiService.DeleteTelegrafsIDExecute(r)
}
/*
* DeleteTelegrafsID Delete a Telegraf configuration
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param telegrafID The Telegraf configuration ID.
* @return ApiDeleteTelegrafsIDRequest
*/
func (a *TelegrafsApiService) DeleteTelegrafsID(ctx _context.Context, telegrafID string) ApiDeleteTelegrafsIDRequest {
return ApiDeleteTelegrafsIDRequest{
ApiService: a,
ctx: ctx,
telegrafID: telegrafID,
}
}
/*
* Execute executes the request
*/
func (a *TelegrafsApiService) DeleteTelegrafsIDExecute(r ApiDeleteTelegrafsIDRequest) error {
var (
localVarHTTPMethod = _nethttp.MethodDelete
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TelegrafsApiService.DeleteTelegrafsID")
if err != nil {
return GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/telegrafs/{telegrafID}"
localVarPath = strings.Replace(localVarPath, "{"+"telegrafID"+"}", _neturl.PathEscape(parameterToString(r.telegrafID, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// 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, "")
}
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
}
if localVarHTTPResponse.StatusCode >= 300 {
body, err := GunzipIfNeeded(localVarHTTPResponse)
if err != nil {
body.Close()
return err
}
localVarBody, err := _ioutil.ReadAll(body)
body.Close()
if err != nil {
return err
}
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
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
}
type ApiGetTelegrafsRequest struct {
ctx _context.Context
ApiService TelegrafsApi
zapTraceSpan *string
orgID *string
}
func (r ApiGetTelegrafsRequest) ZapTraceSpan(zapTraceSpan string) ApiGetTelegrafsRequest {
r.zapTraceSpan = &zapTraceSpan
return r
}
func (r ApiGetTelegrafsRequest) GetZapTraceSpan() *string {
return r.zapTraceSpan
}
func (r ApiGetTelegrafsRequest) OrgID(orgID string) ApiGetTelegrafsRequest {
r.orgID = &orgID
return r
}
func (r ApiGetTelegrafsRequest) GetOrgID() *string {
return r.orgID
}
func (r ApiGetTelegrafsRequest) Execute() (Telegrafs, error) {
return r.ApiService.GetTelegrafsExecute(r)
}
/*
* GetTelegrafs List all Telegraf configurations
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiGetTelegrafsRequest
*/
func (a *TelegrafsApiService) GetTelegrafs(ctx _context.Context) ApiGetTelegrafsRequest {
return ApiGetTelegrafsRequest{
ApiService: a,
ctx: ctx,
}
}
/*
* Execute executes the request
* @return Telegrafs
*/
func (a *TelegrafsApiService) GetTelegrafsExecute(r ApiGetTelegrafsRequest) (Telegrafs, error) {
var (
localVarHTTPMethod = _nethttp.MethodGet
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue Telegrafs
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TelegrafsApiService.GetTelegrafs")
if err != nil {
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/telegrafs"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
if r.orgID != nil {
localVarQueryParams.Add("orgID", parameterToString(*r.orgID, ""))
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// 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, "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
body, err := GunzipIfNeeded(localVarHTTPResponse)
if err != nil {
body.Close()
return localVarReturnValue, err
}
localVarBody, err := _ioutil.ReadAll(body)
body.Close()
if err != nil {
return localVarReturnValue, err
}
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, newErr
}
newErr.model = &v
return localVarReturnValue, newErr
}
body, err := GunzipIfNeeded(localVarHTTPResponse)
if err != nil {
body.Close()
return localVarReturnValue, err
}
localVarBody, err := _ioutil.ReadAll(body)
body.Close()
if err != nil {
return localVarReturnValue, err
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
type ApiGetTelegrafsIDRequest struct {
ctx _context.Context
ApiService TelegrafsApi
telegrafID string
zapTraceSpan *string
accept *string
}
func (r ApiGetTelegrafsIDRequest) TelegrafID(telegrafID string) ApiGetTelegrafsIDRequest {
r.telegrafID = telegrafID
return r
}
func (r ApiGetTelegrafsIDRequest) GetTelegrafID() string {
return r.telegrafID
}
func (r ApiGetTelegrafsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiGetTelegrafsIDRequest {
r.zapTraceSpan = &zapTraceSpan
return r
}
func (r ApiGetTelegrafsIDRequest) GetZapTraceSpan() *string {
return r.zapTraceSpan
}
func (r ApiGetTelegrafsIDRequest) Accept(accept string) ApiGetTelegrafsIDRequest {
r.accept = &accept
return r
}
func (r ApiGetTelegrafsIDRequest) GetAccept() *string {
return r.accept
}
func (r ApiGetTelegrafsIDRequest) Execute() (Telegraf, error) {
return r.ApiService.GetTelegrafsIDExecute(r)
}
/*
* GetTelegrafsID Retrieve a Telegraf configuration
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param telegrafID The Telegraf configuration ID.
* @return ApiGetTelegrafsIDRequest
*/
func (a *TelegrafsApiService) GetTelegrafsID(ctx _context.Context, telegrafID string) ApiGetTelegrafsIDRequest {
return ApiGetTelegrafsIDRequest{
ApiService: a,
ctx: ctx,
telegrafID: telegrafID,
}
}
/*
* Execute executes the request
* @return Telegraf
*/
func (a *TelegrafsApiService) GetTelegrafsIDExecute(r ApiGetTelegrafsIDRequest) (Telegraf, error) {
var (
localVarHTTPMethod = _nethttp.MethodGet
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue Telegraf
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TelegrafsApiService.GetTelegrafsID")
if err != nil {
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/telegrafs/{telegrafID}"
localVarPath = strings.Replace(localVarPath, "{"+"telegrafID"+"}", _neturl.PathEscape(parameterToString(r.telegrafID, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// 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.accept != nil {
localVarHeaderParams["Accept"] = parameterToString(*r.accept, "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
body, err := GunzipIfNeeded(localVarHTTPResponse)
if err != nil {
body.Close()
return localVarReturnValue, err
}
localVarBody, err := _ioutil.ReadAll(body)
body.Close()
if err != nil {
return localVarReturnValue, err
}
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, newErr
}
newErr.model = &v
return localVarReturnValue, newErr
}
body, err := GunzipIfNeeded(localVarHTTPResponse)
if err != nil {
body.Close()
return localVarReturnValue, err
}
localVarBody, err := _ioutil.ReadAll(body)
body.Close()
if err != nil {
return localVarReturnValue, err
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
type ApiPostTelegrafsRequest struct {
ctx _context.Context
ApiService TelegrafsApi
telegrafRequest *TelegrafRequest
zapTraceSpan *string
}
func (r ApiPostTelegrafsRequest) TelegrafRequest(telegrafRequest TelegrafRequest) ApiPostTelegrafsRequest {
r.telegrafRequest = &telegrafRequest
return r
}
func (r ApiPostTelegrafsRequest) GetTelegrafRequest() *TelegrafRequest {
return r.telegrafRequest
}
func (r ApiPostTelegrafsRequest) ZapTraceSpan(zapTraceSpan string) ApiPostTelegrafsRequest {
r.zapTraceSpan = &zapTraceSpan
return r
}
func (r ApiPostTelegrafsRequest) GetZapTraceSpan() *string {
return r.zapTraceSpan
}
func (r ApiPostTelegrafsRequest) Execute() (Telegraf, error) {
return r.ApiService.PostTelegrafsExecute(r)
}
/*
* PostTelegrafs Create a Telegraf configuration
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiPostTelegrafsRequest
*/
func (a *TelegrafsApiService) PostTelegrafs(ctx _context.Context) ApiPostTelegrafsRequest {
return ApiPostTelegrafsRequest{
ApiService: a,
ctx: ctx,
}
}
/*
* Execute executes the request
* @return Telegraf
*/
func (a *TelegrafsApiService) PostTelegrafsExecute(r ApiPostTelegrafsRequest) (Telegraf, error) {
var (
localVarHTTPMethod = _nethttp.MethodPost
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue Telegraf
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TelegrafsApiService.PostTelegrafs")
if err != nil {
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/telegrafs"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
if r.telegrafRequest == nil {
return localVarReturnValue, reportError("telegrafRequest is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// 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, "")
}
// body params
localVarPostBody = r.telegrafRequest
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
body, err := GunzipIfNeeded(localVarHTTPResponse)
if err != nil {
body.Close()
return localVarReturnValue, err
}
localVarBody, err := _ioutil.ReadAll(body)
body.Close()
if err != nil {
return localVarReturnValue, err
}
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, newErr
}
newErr.model = &v
return localVarReturnValue, newErr
}
body, err := GunzipIfNeeded(localVarHTTPResponse)
if err != nil {
body.Close()
return localVarReturnValue, err
}
localVarBody, err := _ioutil.ReadAll(body)
body.Close()
if err != nil {
return localVarReturnValue, err
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}
type ApiPutTelegrafsIDRequest struct {
ctx _context.Context
ApiService TelegrafsApi
telegrafID string
telegrafRequest *TelegrafRequest
zapTraceSpan *string
}
func (r ApiPutTelegrafsIDRequest) TelegrafID(telegrafID string) ApiPutTelegrafsIDRequest {
r.telegrafID = telegrafID
return r
}
func (r ApiPutTelegrafsIDRequest) GetTelegrafID() string {
return r.telegrafID
}
func (r ApiPutTelegrafsIDRequest) TelegrafRequest(telegrafRequest TelegrafRequest) ApiPutTelegrafsIDRequest {
r.telegrafRequest = &telegrafRequest
return r
}
func (r ApiPutTelegrafsIDRequest) GetTelegrafRequest() *TelegrafRequest {
return r.telegrafRequest
}
func (r ApiPutTelegrafsIDRequest) ZapTraceSpan(zapTraceSpan string) ApiPutTelegrafsIDRequest {
r.zapTraceSpan = &zapTraceSpan
return r
}
func (r ApiPutTelegrafsIDRequest) GetZapTraceSpan() *string {
return r.zapTraceSpan
}
func (r ApiPutTelegrafsIDRequest) Execute() (Telegraf, error) {
return r.ApiService.PutTelegrafsIDExecute(r)
}
/*
* PutTelegrafsID Update a Telegraf configuration
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param telegrafID The Telegraf config ID.
* @return ApiPutTelegrafsIDRequest
*/
func (a *TelegrafsApiService) PutTelegrafsID(ctx _context.Context, telegrafID string) ApiPutTelegrafsIDRequest {
return ApiPutTelegrafsIDRequest{
ApiService: a,
ctx: ctx,
telegrafID: telegrafID,
}
}
/*
* Execute executes the request
* @return Telegraf
*/
func (a *TelegrafsApiService) PutTelegrafsIDExecute(r ApiPutTelegrafsIDRequest) (Telegraf, error) {
var (
localVarHTTPMethod = _nethttp.MethodPut
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue Telegraf
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TelegrafsApiService.PutTelegrafsID")
if err != nil {
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/telegrafs/{telegrafID}"
localVarPath = strings.Replace(localVarPath, "{"+"telegrafID"+"}", _neturl.PathEscape(parameterToString(r.telegrafID, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
if r.telegrafRequest == nil {
return localVarReturnValue, reportError("telegrafRequest is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// 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, "")
}
// body params
localVarPostBody = r.telegrafRequest
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, err
}
if localVarHTTPResponse.StatusCode >= 300 {
body, err := GunzipIfNeeded(localVarHTTPResponse)
if err != nil {
body.Close()
return localVarReturnValue, err
}
localVarBody, err := _ioutil.ReadAll(body)
body.Close()
if err != nil {
return localVarReturnValue, err
}
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v Error
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, newErr
}
newErr.model = &v
return localVarReturnValue, newErr
}
body, err := GunzipIfNeeded(localVarHTTPResponse)
if err != nil {
body.Close()
return localVarReturnValue, err
}
localVarBody, err := _ioutil.ReadAll(body)
body.Close()
if err != nil {
return localVarReturnValue, err
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, newErr
}
return localVarReturnValue, nil
}

View File

@ -67,6 +67,8 @@ type APIClient struct {
TasksApi TasksApi
TelegrafsApi TelegrafsApi
UsersApi UsersApi
WriteApi WriteApi
@ -98,6 +100,7 @@ func NewAPIClient(cfg *Configuration) *APIClient {
c.RestoreApi = (*RestoreApiService)(&c.common)
c.SetupApi = (*SetupApiService)(&c.common)
c.TasksApi = (*TasksApiService)(&c.common)
c.TelegrafsApi = (*TelegrafsApiService)(&c.common)
c.UsersApi = (*UsersApiService)(&c.common)
c.WriteApi = (*WriteApiService)(&c.common)

View File

@ -61,10 +61,14 @@ paths:
$ref: "./openapi/src/oss/paths/restore_kv.yml"
/restore/sql:
$ref: "./openapi/src/oss/paths/restore_sql.yml"
/restore/bucket-metadata/{bucketID}:
$ref: "./openapi/src/oss/paths/restore_bucket-metadata_bucketID.yml"
/restore/bucket-metadata:
$ref: "./openapi/src/oss/paths/restore_bucket-metadata.yml"
/restore/shards/{shardID}:
$ref: "./openapi/src/oss/paths/restore_shards_shardID.yml"
"/telegrafs":
$ref: "./openapi/src/common/paths/telegrafs.yml"
"/telegrafs/{telegrafID}":
$ref: "./overrides/paths/telegrafs_telegrafID.yml"
components:
parameters:
TraceSpan:
@ -225,7 +229,15 @@ components:
$ref: "./openapi/src/oss/schemas/SubscriptionManifests.yml"
SubscriptionManifest:
$ref: "./openapi/src/oss/schemas/SubscriptionManifest.yml"
RestoredBucketMappings:
$ref: "./openapi/src/oss/schemas/RestoredBucketMappings.yml"
BucketShardMappings:
$ref: "./openapi/src/oss/schemas/BucketShardMappings.yml"
BucketShardMapping:
$ref: "./openapi/src/oss/schemas/BucketShardMapping.yml"
Telegrafs:
$ref: "./openapi/src/common/schemas/Telegrafs.yml"
TelegrafRequest:
$ref: "./openapi/src/common/schemas/TelegrafRequest.yml"
Telegraf:
$ref: "./openapi/src/common/schemas/Telegraf.yml"

@ -1 +1 @@
Subproject commit 3d27d5c5b8d28a20607fe68f50e98e067e7e3371
Subproject commit b837e212d51bfd9510a486849678c8a8e38e1d8e

View File

@ -0,0 +1,89 @@
get:
operationId: GetTelegrafsID
tags:
- Telegrafs
summary: Retrieve a Telegraf configuration
parameters:
- $ref: "../../openapi/src/common/parameters/TraceSpan.yml"
- in: path
name: telegrafID
schema:
type: string
required: true
description: The Telegraf configuration ID.
- in: header
name: Accept
required: false
schema:
type: string
default: application/json
enum:
- application/json
responses:
"200":
description: Telegraf configuration details
content:
application/json:
schema:
$ref: "../../openapi/src/common/schemas/Telegraf.yml"
default:
description: Unexpected error
content:
application/json:
schema:
$ref: "../../openapi/src/common/schemas/Error.yml"
put:
operationId: PutTelegrafsID
tags:
- Telegrafs
summary: Update a Telegraf configuration
parameters:
- $ref: "../../openapi/src/common/parameters/TraceSpan.yml"
- in: path
name: telegrafID
schema:
type: string
required: true
description: The Telegraf config ID.
requestBody:
description: Telegraf configuration update to apply
required: true
content:
application/json:
schema:
$ref: "../../openapi/src/common/schemas/TelegrafRequest.yml"
responses:
"200":
description: An updated Telegraf configurations
content:
application/json:
schema:
$ref: "../../openapi/src/common/schemas/Telegraf.yml"
default:
description: Unexpected error
content:
application/json:
schema:
$ref: "../../openapi/src/common/schemas/Error.yml"
delete:
operationId: DeleteTelegrafsID
tags:
- Telegrafs
summary: Delete a Telegraf configuration
parameters:
- $ref: "../../openapi/src/common/parameters/TraceSpan.yml"
- in: path
name: telegrafID
schema:
type: string
required: true
description: The Telegraf configuration ID.
responses:
"204":
description: Delete has been accepted
default:
description: Unexpected error
content:
application/json:
schema:
$ref: "../../openapi/src/common/schemas/Error.yml"

View File

@ -20,6 +20,7 @@ type BucketMetadataManifest struct {
OrganizationName string `json:"organizationName"`
BucketID string `json:"bucketID"`
BucketName string `json:"bucketName"`
Description *string `json:"description,omitempty"`
DefaultRetentionPolicy string `json:"defaultRetentionPolicy"`
RetentionPolicies []RetentionPolicyManifest `json:"retentionPolicies"`
}
@ -143,6 +144,38 @@ func (o *BucketMetadataManifest) SetBucketName(v string) {
o.BucketName = v
}
// GetDescription returns the Description field value if set, zero value otherwise.
func (o *BucketMetadataManifest) GetDescription() string {
if o == nil || o.Description == nil {
var ret string
return ret
}
return *o.Description
}
// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *BucketMetadataManifest) GetDescriptionOk() (*string, bool) {
if o == nil || o.Description == nil {
return nil, false
}
return o.Description, true
}
// HasDescription returns a boolean if a field has been set.
func (o *BucketMetadataManifest) HasDescription() bool {
if o != nil && o.Description != nil {
return true
}
return false
}
// SetDescription gets a reference to the given string and assigns it to the Description field.
func (o *BucketMetadataManifest) SetDescription(v string) {
o.Description = &v
}
// GetDefaultRetentionPolicy returns the DefaultRetentionPolicy field value
func (o *BucketMetadataManifest) GetDefaultRetentionPolicy() string {
if o == nil {
@ -205,6 +238,9 @@ func (o BucketMetadataManifest) MarshalJSON() ([]byte, error) {
if true {
toSerialize["bucketName"] = o.BucketName
}
if o.Description != nil {
toSerialize["description"] = o.Description
}
if true {
toSerialize["defaultRetentionPolicy"] = o.DefaultRetentionPolicy
}

View File

@ -16,16 +16,18 @@ import (
// BucketShardMapping struct for BucketShardMapping
type BucketShardMapping struct {
OldId *int64 `json:"oldId,omitempty"`
NewId *int64 `json:"newId,omitempty"`
OldId int64 `json:"oldId"`
NewId int64 `json:"newId"`
}
// NewBucketShardMapping instantiates a new BucketShardMapping object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewBucketShardMapping() *BucketShardMapping {
func NewBucketShardMapping(oldId int64, newId int64) *BucketShardMapping {
this := BucketShardMapping{}
this.OldId = oldId
this.NewId = newId
return &this
}
@ -37,76 +39,60 @@ func NewBucketShardMappingWithDefaults() *BucketShardMapping {
return &this
}
// GetOldId returns the OldId field value if set, zero value otherwise.
// GetOldId returns the OldId field value
func (o *BucketShardMapping) GetOldId() int64 {
if o == nil || o.OldId == nil {
if o == nil {
var ret int64
return ret
}
return *o.OldId
return o.OldId
}
// GetOldIdOk returns a tuple with the OldId field value if set, nil otherwise
// GetOldIdOk returns a tuple with the OldId field value
// and a boolean to check if the value has been set.
func (o *BucketShardMapping) GetOldIdOk() (*int64, bool) {
if o == nil || o.OldId == nil {
if o == nil {
return nil, false
}
return o.OldId, true
return &o.OldId, true
}
// HasOldId returns a boolean if a field has been set.
func (o *BucketShardMapping) HasOldId() bool {
if o != nil && o.OldId != nil {
return true
}
return false
}
// SetOldId gets a reference to the given int64 and assigns it to the OldId field.
// SetOldId sets field value
func (o *BucketShardMapping) SetOldId(v int64) {
o.OldId = &v
o.OldId = v
}
// GetNewId returns the NewId field value if set, zero value otherwise.
// GetNewId returns the NewId field value
func (o *BucketShardMapping) GetNewId() int64 {
if o == nil || o.NewId == nil {
if o == nil {
var ret int64
return ret
}
return *o.NewId
return o.NewId
}
// GetNewIdOk returns a tuple with the NewId field value if set, nil otherwise
// GetNewIdOk returns a tuple with the NewId field value
// and a boolean to check if the value has been set.
func (o *BucketShardMapping) GetNewIdOk() (*int64, bool) {
if o == nil || o.NewId == nil {
if o == nil {
return nil, false
}
return o.NewId, true
return &o.NewId, true
}
// HasNewId returns a boolean if a field has been set.
func (o *BucketShardMapping) HasNewId() bool {
if o != nil && o.NewId != nil {
return true
}
return false
}
// SetNewId gets a reference to the given int64 and assigns it to the NewId field.
// SetNewId sets field value
func (o *BucketShardMapping) SetNewId(v int64) {
o.NewId = &v
o.NewId = v
}
func (o BucketShardMapping) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.OldId != nil {
if true {
toSerialize["oldId"] = o.OldId
}
if o.NewId != nil {
if true {
toSerialize["newId"] = o.NewId
}
return json.Marshal(toSerialize)

View File

@ -0,0 +1,165 @@
/*
* 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 (
"encoding/json"
)
// RestoredBucketMappings struct for RestoredBucketMappings
type RestoredBucketMappings struct {
// New ID of the restored bucket
Id string `json:"id"`
Name string `json:"name"`
ShardMappings []BucketShardMapping `json:"shardMappings"`
}
// NewRestoredBucketMappings instantiates a new RestoredBucketMappings object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewRestoredBucketMappings(id string, name string, shardMappings []BucketShardMapping) *RestoredBucketMappings {
this := RestoredBucketMappings{}
this.Id = id
this.Name = name
this.ShardMappings = shardMappings
return &this
}
// NewRestoredBucketMappingsWithDefaults instantiates a new RestoredBucketMappings object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewRestoredBucketMappingsWithDefaults() *RestoredBucketMappings {
this := RestoredBucketMappings{}
return &this
}
// GetId returns the Id field value
func (o *RestoredBucketMappings) GetId() string {
if o == nil {
var ret string
return ret
}
return o.Id
}
// GetIdOk returns a tuple with the Id field value
// and a boolean to check if the value has been set.
func (o *RestoredBucketMappings) GetIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Id, true
}
// SetId sets field value
func (o *RestoredBucketMappings) SetId(v string) {
o.Id = v
}
// GetName returns the Name field value
func (o *RestoredBucketMappings) GetName() string {
if o == nil {
var ret string
return ret
}
return o.Name
}
// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *RestoredBucketMappings) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}
// SetName sets field value
func (o *RestoredBucketMappings) SetName(v string) {
o.Name = v
}
// GetShardMappings returns the ShardMappings field value
func (o *RestoredBucketMappings) GetShardMappings() []BucketShardMapping {
if o == nil {
var ret []BucketShardMapping
return ret
}
return o.ShardMappings
}
// GetShardMappingsOk returns a tuple with the ShardMappings field value
// and a boolean to check if the value has been set.
func (o *RestoredBucketMappings) GetShardMappingsOk() (*[]BucketShardMapping, bool) {
if o == nil {
return nil, false
}
return &o.ShardMappings, true
}
// SetShardMappings sets field value
func (o *RestoredBucketMappings) SetShardMappings(v []BucketShardMapping) {
o.ShardMappings = v
}
func (o RestoredBucketMappings) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if true {
toSerialize["id"] = o.Id
}
if true {
toSerialize["name"] = o.Name
}
if true {
toSerialize["shardMappings"] = o.ShardMappings
}
return json.Marshal(toSerialize)
}
type NullableRestoredBucketMappings struct {
value *RestoredBucketMappings
isSet bool
}
func (v NullableRestoredBucketMappings) Get() *RestoredBucketMappings {
return v.value
}
func (v *NullableRestoredBucketMappings) Set(val *RestoredBucketMappings) {
v.value = val
v.isSet = true
}
func (v NullableRestoredBucketMappings) IsSet() bool {
return v.isSet
}
func (v *NullableRestoredBucketMappings) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableRestoredBucketMappings(val *RestoredBucketMappings) *NullableRestoredBucketMappings {
return &NullableRestoredBucketMappings{value: val, isSet: true}
}
func (v NullableRestoredBucketMappings) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableRestoredBucketMappings) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

365
api/model_telegraf.gen.go Normal file
View File

@ -0,0 +1,365 @@
/*
* 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 (
"encoding/json"
)
// Telegraf struct for Telegraf
type Telegraf struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Metadata *TelegrafRequestMetadata `json:"metadata,omitempty"`
Config *string `json:"config,omitempty"`
OrgID *string `json:"orgID,omitempty"`
Id *string `json:"id,omitempty"`
Links *TelegrafAllOfLinks `json:"links,omitempty"`
Labels *[]Label `json:"labels,omitempty"`
}
// NewTelegraf instantiates a new Telegraf object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewTelegraf() *Telegraf {
this := Telegraf{}
return &this
}
// NewTelegrafWithDefaults instantiates a new Telegraf object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewTelegrafWithDefaults() *Telegraf {
this := Telegraf{}
return &this
}
// GetName returns the Name field value if set, zero value otherwise.
func (o *Telegraf) GetName() string {
if o == nil || o.Name == nil {
var ret string
return ret
}
return *o.Name
}
// GetNameOk returns a tuple with the Name field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Telegraf) GetNameOk() (*string, bool) {
if o == nil || o.Name == nil {
return nil, false
}
return o.Name, true
}
// HasName returns a boolean if a field has been set.
func (o *Telegraf) HasName() bool {
if o != nil && o.Name != nil {
return true
}
return false
}
// SetName gets a reference to the given string and assigns it to the Name field.
func (o *Telegraf) SetName(v string) {
o.Name = &v
}
// GetDescription returns the Description field value if set, zero value otherwise.
func (o *Telegraf) GetDescription() string {
if o == nil || o.Description == nil {
var ret string
return ret
}
return *o.Description
}
// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Telegraf) GetDescriptionOk() (*string, bool) {
if o == nil || o.Description == nil {
return nil, false
}
return o.Description, true
}
// HasDescription returns a boolean if a field has been set.
func (o *Telegraf) HasDescription() bool {
if o != nil && o.Description != nil {
return true
}
return false
}
// SetDescription gets a reference to the given string and assigns it to the Description field.
func (o *Telegraf) SetDescription(v string) {
o.Description = &v
}
// GetMetadata returns the Metadata field value if set, zero value otherwise.
func (o *Telegraf) GetMetadata() TelegrafRequestMetadata {
if o == nil || o.Metadata == nil {
var ret TelegrafRequestMetadata
return ret
}
return *o.Metadata
}
// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Telegraf) GetMetadataOk() (*TelegrafRequestMetadata, bool) {
if o == nil || o.Metadata == nil {
return nil, false
}
return o.Metadata, true
}
// HasMetadata returns a boolean if a field has been set.
func (o *Telegraf) HasMetadata() bool {
if o != nil && o.Metadata != nil {
return true
}
return false
}
// SetMetadata gets a reference to the given TelegrafRequestMetadata and assigns it to the Metadata field.
func (o *Telegraf) SetMetadata(v TelegrafRequestMetadata) {
o.Metadata = &v
}
// GetConfig returns the Config field value if set, zero value otherwise.
func (o *Telegraf) GetConfig() string {
if o == nil || o.Config == nil {
var ret string
return ret
}
return *o.Config
}
// GetConfigOk returns a tuple with the Config field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Telegraf) GetConfigOk() (*string, bool) {
if o == nil || o.Config == nil {
return nil, false
}
return o.Config, true
}
// HasConfig returns a boolean if a field has been set.
func (o *Telegraf) HasConfig() bool {
if o != nil && o.Config != nil {
return true
}
return false
}
// SetConfig gets a reference to the given string and assigns it to the Config field.
func (o *Telegraf) SetConfig(v string) {
o.Config = &v
}
// GetOrgID returns the OrgID field value if set, zero value otherwise.
func (o *Telegraf) GetOrgID() string {
if o == nil || o.OrgID == nil {
var ret string
return ret
}
return *o.OrgID
}
// GetOrgIDOk returns a tuple with the OrgID field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Telegraf) GetOrgIDOk() (*string, bool) {
if o == nil || o.OrgID == nil {
return nil, false
}
return o.OrgID, true
}
// HasOrgID returns a boolean if a field has been set.
func (o *Telegraf) HasOrgID() bool {
if o != nil && o.OrgID != nil {
return true
}
return false
}
// SetOrgID gets a reference to the given string and assigns it to the OrgID field.
func (o *Telegraf) SetOrgID(v string) {
o.OrgID = &v
}
// GetId returns the Id field value if set, zero value otherwise.
func (o *Telegraf) GetId() string {
if o == nil || o.Id == nil {
var ret string
return ret
}
return *o.Id
}
// GetIdOk returns a tuple with the Id field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Telegraf) GetIdOk() (*string, bool) {
if o == nil || o.Id == nil {
return nil, false
}
return o.Id, true
}
// HasId returns a boolean if a field has been set.
func (o *Telegraf) HasId() bool {
if o != nil && o.Id != nil {
return true
}
return false
}
// SetId gets a reference to the given string and assigns it to the Id field.
func (o *Telegraf) SetId(v string) {
o.Id = &v
}
// GetLinks returns the Links field value if set, zero value otherwise.
func (o *Telegraf) GetLinks() TelegrafAllOfLinks {
if o == nil || o.Links == nil {
var ret TelegrafAllOfLinks
return ret
}
return *o.Links
}
// GetLinksOk returns a tuple with the Links field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Telegraf) GetLinksOk() (*TelegrafAllOfLinks, bool) {
if o == nil || o.Links == nil {
return nil, false
}
return o.Links, true
}
// HasLinks returns a boolean if a field has been set.
func (o *Telegraf) HasLinks() bool {
if o != nil && o.Links != nil {
return true
}
return false
}
// SetLinks gets a reference to the given TelegrafAllOfLinks and assigns it to the Links field.
func (o *Telegraf) SetLinks(v TelegrafAllOfLinks) {
o.Links = &v
}
// GetLabels returns the Labels field value if set, zero value otherwise.
func (o *Telegraf) GetLabels() []Label {
if o == nil || o.Labels == nil {
var ret []Label
return ret
}
return *o.Labels
}
// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Telegraf) GetLabelsOk() (*[]Label, bool) {
if o == nil || o.Labels == nil {
return nil, false
}
return o.Labels, true
}
// HasLabels returns a boolean if a field has been set.
func (o *Telegraf) HasLabels() bool {
if o != nil && o.Labels != nil {
return true
}
return false
}
// SetLabels gets a reference to the given []Label and assigns it to the Labels field.
func (o *Telegraf) SetLabels(v []Label) {
o.Labels = &v
}
func (o Telegraf) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Name != nil {
toSerialize["name"] = o.Name
}
if o.Description != nil {
toSerialize["description"] = o.Description
}
if o.Metadata != nil {
toSerialize["metadata"] = o.Metadata
}
if o.Config != nil {
toSerialize["config"] = o.Config
}
if o.OrgID != nil {
toSerialize["orgID"] = o.OrgID
}
if o.Id != nil {
toSerialize["id"] = o.Id
}
if o.Links != nil {
toSerialize["links"] = o.Links
}
if o.Labels != nil {
toSerialize["labels"] = o.Labels
}
return json.Marshal(toSerialize)
}
type NullableTelegraf struct {
value *Telegraf
isSet bool
}
func (v NullableTelegraf) Get() *Telegraf {
return v.value
}
func (v *NullableTelegraf) Set(val *Telegraf) {
v.value = val
v.isSet = true
}
func (v NullableTelegraf) IsSet() bool {
return v.isSet
}
func (v *NullableTelegraf) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTelegraf(val *Telegraf) *NullableTelegraf {
return &NullableTelegraf{value: val, isSet: true}
}
func (v NullableTelegraf) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTelegraf) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,185 @@
/*
* 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 (
"encoding/json"
)
// TelegrafAllOf struct for TelegrafAllOf
type TelegrafAllOf struct {
Id *string `json:"id,omitempty"`
Links *TelegrafAllOfLinks `json:"links,omitempty"`
Labels *[]Label `json:"labels,omitempty"`
}
// NewTelegrafAllOf instantiates a new TelegrafAllOf object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewTelegrafAllOf() *TelegrafAllOf {
this := TelegrafAllOf{}
return &this
}
// NewTelegrafAllOfWithDefaults instantiates a new TelegrafAllOf object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewTelegrafAllOfWithDefaults() *TelegrafAllOf {
this := TelegrafAllOf{}
return &this
}
// GetId returns the Id field value if set, zero value otherwise.
func (o *TelegrafAllOf) GetId() string {
if o == nil || o.Id == nil {
var ret string
return ret
}
return *o.Id
}
// GetIdOk returns a tuple with the Id field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafAllOf) GetIdOk() (*string, bool) {
if o == nil || o.Id == nil {
return nil, false
}
return o.Id, true
}
// HasId returns a boolean if a field has been set.
func (o *TelegrafAllOf) HasId() bool {
if o != nil && o.Id != nil {
return true
}
return false
}
// SetId gets a reference to the given string and assigns it to the Id field.
func (o *TelegrafAllOf) SetId(v string) {
o.Id = &v
}
// GetLinks returns the Links field value if set, zero value otherwise.
func (o *TelegrafAllOf) GetLinks() TelegrafAllOfLinks {
if o == nil || o.Links == nil {
var ret TelegrafAllOfLinks
return ret
}
return *o.Links
}
// GetLinksOk returns a tuple with the Links field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafAllOf) GetLinksOk() (*TelegrafAllOfLinks, bool) {
if o == nil || o.Links == nil {
return nil, false
}
return o.Links, true
}
// HasLinks returns a boolean if a field has been set.
func (o *TelegrafAllOf) HasLinks() bool {
if o != nil && o.Links != nil {
return true
}
return false
}
// SetLinks gets a reference to the given TelegrafAllOfLinks and assigns it to the Links field.
func (o *TelegrafAllOf) SetLinks(v TelegrafAllOfLinks) {
o.Links = &v
}
// GetLabels returns the Labels field value if set, zero value otherwise.
func (o *TelegrafAllOf) GetLabels() []Label {
if o == nil || o.Labels == nil {
var ret []Label
return ret
}
return *o.Labels
}
// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafAllOf) GetLabelsOk() (*[]Label, bool) {
if o == nil || o.Labels == nil {
return nil, false
}
return o.Labels, true
}
// HasLabels returns a boolean if a field has been set.
func (o *TelegrafAllOf) HasLabels() bool {
if o != nil && o.Labels != nil {
return true
}
return false
}
// SetLabels gets a reference to the given []Label and assigns it to the Labels field.
func (o *TelegrafAllOf) SetLabels(v []Label) {
o.Labels = &v
}
func (o TelegrafAllOf) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Id != nil {
toSerialize["id"] = o.Id
}
if o.Links != nil {
toSerialize["links"] = o.Links
}
if o.Labels != nil {
toSerialize["labels"] = o.Labels
}
return json.Marshal(toSerialize)
}
type NullableTelegrafAllOf struct {
value *TelegrafAllOf
isSet bool
}
func (v NullableTelegrafAllOf) Get() *TelegrafAllOf {
return v.value
}
func (v *NullableTelegrafAllOf) Set(val *TelegrafAllOf) {
v.value = val
v.isSet = true
}
func (v NullableTelegrafAllOf) IsSet() bool {
return v.isSet
}
func (v *NullableTelegrafAllOf) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTelegrafAllOf(val *TelegrafAllOf) *NullableTelegrafAllOf {
return &NullableTelegrafAllOf{value: val, isSet: true}
}
func (v NullableTelegrafAllOf) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTelegrafAllOf) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,225 @@
/*
* 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 (
"encoding/json"
)
// TelegrafAllOfLinks struct for TelegrafAllOfLinks
type TelegrafAllOfLinks struct {
// URI of resource.
Self *string `json:"self,omitempty"`
// URI of resource.
Labels *string `json:"labels,omitempty"`
// URI of resource.
Members *string `json:"members,omitempty"`
// URI of resource.
Owners *string `json:"owners,omitempty"`
}
// NewTelegrafAllOfLinks instantiates a new TelegrafAllOfLinks object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewTelegrafAllOfLinks() *TelegrafAllOfLinks {
this := TelegrafAllOfLinks{}
return &this
}
// NewTelegrafAllOfLinksWithDefaults instantiates a new TelegrafAllOfLinks object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewTelegrafAllOfLinksWithDefaults() *TelegrafAllOfLinks {
this := TelegrafAllOfLinks{}
return &this
}
// GetSelf returns the Self field value if set, zero value otherwise.
func (o *TelegrafAllOfLinks) GetSelf() string {
if o == nil || o.Self == nil {
var ret string
return ret
}
return *o.Self
}
// GetSelfOk returns a tuple with the Self field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafAllOfLinks) GetSelfOk() (*string, bool) {
if o == nil || o.Self == nil {
return nil, false
}
return o.Self, true
}
// HasSelf returns a boolean if a field has been set.
func (o *TelegrafAllOfLinks) HasSelf() bool {
if o != nil && o.Self != nil {
return true
}
return false
}
// SetSelf gets a reference to the given string and assigns it to the Self field.
func (o *TelegrafAllOfLinks) SetSelf(v string) {
o.Self = &v
}
// GetLabels returns the Labels field value if set, zero value otherwise.
func (o *TelegrafAllOfLinks) GetLabels() string {
if o == nil || o.Labels == nil {
var ret string
return ret
}
return *o.Labels
}
// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafAllOfLinks) GetLabelsOk() (*string, bool) {
if o == nil || o.Labels == nil {
return nil, false
}
return o.Labels, true
}
// HasLabels returns a boolean if a field has been set.
func (o *TelegrafAllOfLinks) HasLabels() bool {
if o != nil && o.Labels != nil {
return true
}
return false
}
// SetLabels gets a reference to the given string and assigns it to the Labels field.
func (o *TelegrafAllOfLinks) SetLabels(v string) {
o.Labels = &v
}
// GetMembers returns the Members field value if set, zero value otherwise.
func (o *TelegrafAllOfLinks) GetMembers() string {
if o == nil || o.Members == nil {
var ret string
return ret
}
return *o.Members
}
// GetMembersOk returns a tuple with the Members field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafAllOfLinks) GetMembersOk() (*string, bool) {
if o == nil || o.Members == nil {
return nil, false
}
return o.Members, true
}
// HasMembers returns a boolean if a field has been set.
func (o *TelegrafAllOfLinks) HasMembers() bool {
if o != nil && o.Members != nil {
return true
}
return false
}
// SetMembers gets a reference to the given string and assigns it to the Members field.
func (o *TelegrafAllOfLinks) SetMembers(v string) {
o.Members = &v
}
// GetOwners returns the Owners field value if set, zero value otherwise.
func (o *TelegrafAllOfLinks) GetOwners() string {
if o == nil || o.Owners == nil {
var ret string
return ret
}
return *o.Owners
}
// GetOwnersOk returns a tuple with the Owners field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafAllOfLinks) GetOwnersOk() (*string, bool) {
if o == nil || o.Owners == nil {
return nil, false
}
return o.Owners, true
}
// HasOwners returns a boolean if a field has been set.
func (o *TelegrafAllOfLinks) HasOwners() bool {
if o != nil && o.Owners != nil {
return true
}
return false
}
// SetOwners gets a reference to the given string and assigns it to the Owners field.
func (o *TelegrafAllOfLinks) SetOwners(v string) {
o.Owners = &v
}
func (o TelegrafAllOfLinks) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Self != nil {
toSerialize["self"] = o.Self
}
if o.Labels != nil {
toSerialize["labels"] = o.Labels
}
if o.Members != nil {
toSerialize["members"] = o.Members
}
if o.Owners != nil {
toSerialize["owners"] = o.Owners
}
return json.Marshal(toSerialize)
}
type NullableTelegrafAllOfLinks struct {
value *TelegrafAllOfLinks
isSet bool
}
func (v NullableTelegrafAllOfLinks) Get() *TelegrafAllOfLinks {
return v.value
}
func (v *NullableTelegrafAllOfLinks) Set(val *TelegrafAllOfLinks) {
v.value = val
v.isSet = true
}
func (v NullableTelegrafAllOfLinks) IsSet() bool {
return v.isSet
}
func (v *NullableTelegrafAllOfLinks) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTelegrafAllOfLinks(val *TelegrafAllOfLinks) *NullableTelegrafAllOfLinks {
return &NullableTelegrafAllOfLinks{value: val, isSet: true}
}
func (v NullableTelegrafAllOfLinks) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTelegrafAllOfLinks) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,257 @@
/*
* 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 (
"encoding/json"
)
// TelegrafRequest struct for TelegrafRequest
type TelegrafRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Metadata *TelegrafRequestMetadata `json:"metadata,omitempty"`
Config *string `json:"config,omitempty"`
OrgID *string `json:"orgID,omitempty"`
}
// NewTelegrafRequest instantiates a new TelegrafRequest object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewTelegrafRequest() *TelegrafRequest {
this := TelegrafRequest{}
return &this
}
// NewTelegrafRequestWithDefaults instantiates a new TelegrafRequest object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewTelegrafRequestWithDefaults() *TelegrafRequest {
this := TelegrafRequest{}
return &this
}
// GetName returns the Name field value if set, zero value otherwise.
func (o *TelegrafRequest) GetName() string {
if o == nil || o.Name == nil {
var ret string
return ret
}
return *o.Name
}
// GetNameOk returns a tuple with the Name field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafRequest) GetNameOk() (*string, bool) {
if o == nil || o.Name == nil {
return nil, false
}
return o.Name, true
}
// HasName returns a boolean if a field has been set.
func (o *TelegrafRequest) HasName() bool {
if o != nil && o.Name != nil {
return true
}
return false
}
// SetName gets a reference to the given string and assigns it to the Name field.
func (o *TelegrafRequest) SetName(v string) {
o.Name = &v
}
// GetDescription returns the Description field value if set, zero value otherwise.
func (o *TelegrafRequest) GetDescription() string {
if o == nil || o.Description == nil {
var ret string
return ret
}
return *o.Description
}
// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafRequest) GetDescriptionOk() (*string, bool) {
if o == nil || o.Description == nil {
return nil, false
}
return o.Description, true
}
// HasDescription returns a boolean if a field has been set.
func (o *TelegrafRequest) HasDescription() bool {
if o != nil && o.Description != nil {
return true
}
return false
}
// SetDescription gets a reference to the given string and assigns it to the Description field.
func (o *TelegrafRequest) SetDescription(v string) {
o.Description = &v
}
// GetMetadata returns the Metadata field value if set, zero value otherwise.
func (o *TelegrafRequest) GetMetadata() TelegrafRequestMetadata {
if o == nil || o.Metadata == nil {
var ret TelegrafRequestMetadata
return ret
}
return *o.Metadata
}
// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafRequest) GetMetadataOk() (*TelegrafRequestMetadata, bool) {
if o == nil || o.Metadata == nil {
return nil, false
}
return o.Metadata, true
}
// HasMetadata returns a boolean if a field has been set.
func (o *TelegrafRequest) HasMetadata() bool {
if o != nil && o.Metadata != nil {
return true
}
return false
}
// SetMetadata gets a reference to the given TelegrafRequestMetadata and assigns it to the Metadata field.
func (o *TelegrafRequest) SetMetadata(v TelegrafRequestMetadata) {
o.Metadata = &v
}
// GetConfig returns the Config field value if set, zero value otherwise.
func (o *TelegrafRequest) GetConfig() string {
if o == nil || o.Config == nil {
var ret string
return ret
}
return *o.Config
}
// GetConfigOk returns a tuple with the Config field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafRequest) GetConfigOk() (*string, bool) {
if o == nil || o.Config == nil {
return nil, false
}
return o.Config, true
}
// HasConfig returns a boolean if a field has been set.
func (o *TelegrafRequest) HasConfig() bool {
if o != nil && o.Config != nil {
return true
}
return false
}
// SetConfig gets a reference to the given string and assigns it to the Config field.
func (o *TelegrafRequest) SetConfig(v string) {
o.Config = &v
}
// GetOrgID returns the OrgID field value if set, zero value otherwise.
func (o *TelegrafRequest) GetOrgID() string {
if o == nil || o.OrgID == nil {
var ret string
return ret
}
return *o.OrgID
}
// GetOrgIDOk returns a tuple with the OrgID field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafRequest) GetOrgIDOk() (*string, bool) {
if o == nil || o.OrgID == nil {
return nil, false
}
return o.OrgID, true
}
// HasOrgID returns a boolean if a field has been set.
func (o *TelegrafRequest) HasOrgID() bool {
if o != nil && o.OrgID != nil {
return true
}
return false
}
// SetOrgID gets a reference to the given string and assigns it to the OrgID field.
func (o *TelegrafRequest) SetOrgID(v string) {
o.OrgID = &v
}
func (o TelegrafRequest) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Name != nil {
toSerialize["name"] = o.Name
}
if o.Description != nil {
toSerialize["description"] = o.Description
}
if o.Metadata != nil {
toSerialize["metadata"] = o.Metadata
}
if o.Config != nil {
toSerialize["config"] = o.Config
}
if o.OrgID != nil {
toSerialize["orgID"] = o.OrgID
}
return json.Marshal(toSerialize)
}
type NullableTelegrafRequest struct {
value *TelegrafRequest
isSet bool
}
func (v NullableTelegrafRequest) Get() *TelegrafRequest {
return v.value
}
func (v *NullableTelegrafRequest) Set(val *TelegrafRequest) {
v.value = val
v.isSet = true
}
func (v NullableTelegrafRequest) IsSet() bool {
return v.isSet
}
func (v *NullableTelegrafRequest) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTelegrafRequest(val *TelegrafRequest) *NullableTelegrafRequest {
return &NullableTelegrafRequest{value: val, isSet: true}
}
func (v NullableTelegrafRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTelegrafRequest) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,113 @@
/*
* 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 (
"encoding/json"
)
// TelegrafRequestMetadata struct for TelegrafRequestMetadata
type TelegrafRequestMetadata struct {
Buckets *[]string `json:"buckets,omitempty"`
}
// NewTelegrafRequestMetadata instantiates a new TelegrafRequestMetadata object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewTelegrafRequestMetadata() *TelegrafRequestMetadata {
this := TelegrafRequestMetadata{}
return &this
}
// NewTelegrafRequestMetadataWithDefaults instantiates a new TelegrafRequestMetadata object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewTelegrafRequestMetadataWithDefaults() *TelegrafRequestMetadata {
this := TelegrafRequestMetadata{}
return &this
}
// GetBuckets returns the Buckets field value if set, zero value otherwise.
func (o *TelegrafRequestMetadata) GetBuckets() []string {
if o == nil || o.Buckets == nil {
var ret []string
return ret
}
return *o.Buckets
}
// GetBucketsOk returns a tuple with the Buckets field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TelegrafRequestMetadata) GetBucketsOk() (*[]string, bool) {
if o == nil || o.Buckets == nil {
return nil, false
}
return o.Buckets, true
}
// HasBuckets returns a boolean if a field has been set.
func (o *TelegrafRequestMetadata) HasBuckets() bool {
if o != nil && o.Buckets != nil {
return true
}
return false
}
// SetBuckets gets a reference to the given []string and assigns it to the Buckets field.
func (o *TelegrafRequestMetadata) SetBuckets(v []string) {
o.Buckets = &v
}
func (o TelegrafRequestMetadata) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Buckets != nil {
toSerialize["buckets"] = o.Buckets
}
return json.Marshal(toSerialize)
}
type NullableTelegrafRequestMetadata struct {
value *TelegrafRequestMetadata
isSet bool
}
func (v NullableTelegrafRequestMetadata) Get() *TelegrafRequestMetadata {
return v.value
}
func (v *NullableTelegrafRequestMetadata) Set(val *TelegrafRequestMetadata) {
v.value = val
v.isSet = true
}
func (v NullableTelegrafRequestMetadata) IsSet() bool {
return v.isSet
}
func (v *NullableTelegrafRequestMetadata) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTelegrafRequestMetadata(val *TelegrafRequestMetadata) *NullableTelegrafRequestMetadata {
return &NullableTelegrafRequestMetadata{value: val, isSet: true}
}
func (v NullableTelegrafRequestMetadata) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTelegrafRequestMetadata) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

113
api/model_telegrafs.gen.go Normal file
View File

@ -0,0 +1,113 @@
/*
* 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 (
"encoding/json"
)
// Telegrafs struct for Telegrafs
type Telegrafs struct {
Configurations *[]Telegraf `json:"configurations,omitempty"`
}
// NewTelegrafs instantiates a new Telegrafs object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewTelegrafs() *Telegrafs {
this := Telegrafs{}
return &this
}
// NewTelegrafsWithDefaults instantiates a new Telegrafs object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewTelegrafsWithDefaults() *Telegrafs {
this := Telegrafs{}
return &this
}
// GetConfigurations returns the Configurations field value if set, zero value otherwise.
func (o *Telegrafs) GetConfigurations() []Telegraf {
if o == nil || o.Configurations == nil {
var ret []Telegraf
return ret
}
return *o.Configurations
}
// GetConfigurationsOk returns a tuple with the Configurations field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Telegrafs) GetConfigurationsOk() (*[]Telegraf, bool) {
if o == nil || o.Configurations == nil {
return nil, false
}
return o.Configurations, true
}
// HasConfigurations returns a boolean if a field has been set.
func (o *Telegrafs) HasConfigurations() bool {
if o != nil && o.Configurations != nil {
return true
}
return false
}
// SetConfigurations gets a reference to the given []Telegraf and assigns it to the Configurations field.
func (o *Telegrafs) SetConfigurations(v []Telegraf) {
o.Configurations = &v
}
func (o Telegrafs) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Configurations != nil {
toSerialize["configurations"] = o.Configurations
}
return json.Marshal(toSerialize)
}
type NullableTelegrafs struct {
value *Telegrafs
isSet bool
}
func (v NullableTelegrafs) Get() *Telegrafs {
return v.value
}
func (v *NullableTelegrafs) Set(val *Telegrafs) {
v.value = val
v.isSet = true
}
func (v NullableTelegrafs) IsSet() bool {
return v.isSet
}
func (v *NullableTelegrafs) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTelegrafs(val *Telegrafs) *NullableTelegrafs {
return &NullableTelegrafs{value: val, isSet: true}
}
func (v NullableTelegrafs) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTelegrafs) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

View File

@ -0,0 +1,175 @@
package telegrafs
import (
"context"
"errors"
"fmt"
"github.com/influxdata/influx-cli/v2/api"
"github.com/influxdata/influx-cli/v2/clients"
"github.com/influxdata/influx-cli/v2/pkg/influxid"
)
type Client struct {
clients.CLI
api.TelegrafsApi
api.OrganizationsApi
}
type telegrafPrintOpts struct {
graf *api.Telegraf
grafs *api.Telegrafs
}
type ListParams struct {
clients.OrgParams
Id string
}
func (c Client) List(ctx context.Context, params *ListParams) error {
if params.Id == "" && !params.OrgID.Valid() && params.OrgName == "" && c.ActiveConfig.Org == "" {
return errors.New("at least one of org, org-id, or id must be provided")
}
if params.Id != "" {
telegraf, err := c.GetTelegrafsID(ctx, params.Id).Execute()
if err != nil {
return fmt.Errorf("failed to get telegraf config with ID %q: %w", params.Id, err)
}
return c.printTelegrafs(telegrafPrintOpts{graf: &telegraf})
}
orgID, err := c.getOrgID(ctx, params.OrgID, params.OrgName)
if err != nil {
return err
}
telegrafs, err := c.GetTelegrafs(ctx).OrgID(orgID).Execute()
if err != nil {
return fmt.Errorf("failed to get telegraf configs from org %q: %w", orgID, err)
}
return c.printTelegrafs(telegrafPrintOpts{grafs: &telegrafs})
}
type CreateParams struct {
clients.OrgParams
Desc string
Config string
Name string
}
func (c Client) Create(ctx context.Context, params *CreateParams) error {
orgID, err := c.getOrgID(ctx, params.OrgID, params.OrgName)
if err != nil {
return err
}
newTelegraf := api.TelegrafRequest{
Name: &params.Name,
Description: &params.Desc,
Config: &params.Config,
OrgID: &orgID,
}
graf, err := c.PostTelegrafs(ctx).TelegrafRequest(newTelegraf).Execute()
if err != nil {
return fmt.Errorf("failed to create telegraf config %q: %w", params.Name, err)
}
return c.printTelegrafs(telegrafPrintOpts{graf: &graf})
}
type RemoveParams struct {
Ids []string
}
func (c Client) Remove(ctx context.Context, params *RemoveParams) error {
for _, rawID := range params.Ids {
if err := c.DeleteTelegrafsID(ctx, rawID).Execute(); err != nil {
return fmt.Errorf("failed to delete telegraf config with ID %q: %w", rawID, err)
}
}
return nil
}
type UpdateParams struct {
Desc string
Config string
Name string
Id string
}
func (c Client) Update(ctx context.Context, params *UpdateParams) error {
oldTelegraf, err := c.GetTelegrafsID(ctx, params.Id).Execute()
if err != nil {
return fmt.Errorf("failed to find telegraf config with ID %q: %w", params.Id, err)
}
orgID := oldTelegraf.OrgID
updateTelegraf := api.TelegrafRequest{
Name: &params.Name,
Description: &params.Desc,
Config: &params.Config,
OrgID: orgID,
}
graf, err := c.PutTelegrafsID(ctx, params.Id).TelegrafRequest(updateTelegraf).Execute()
if err != nil {
return fmt.Errorf("failed to update telegraf config with ID %q: %w", params.Id, err)
}
return c.printTelegrafs(telegrafPrintOpts{graf: &graf})
}
func (c Client) printTelegrafs(opts telegrafPrintOpts) error {
if c.PrintAsJSON {
var v interface{}
if opts.graf != nil {
v = opts.graf
} else {
v = opts.grafs
}
return c.PrintJSON(v)
}
headers := []string{"ID", "OrgID", "Name", "Description"}
telegrafs := opts.grafs.GetConfigurations()
if opts.graf != nil {
telegrafs = append(telegrafs, *opts.graf)
}
var rows []map[string]interface{}
for _, u := range telegrafs {
row := map[string]interface{}{
"ID": u.GetId(),
"OrgID": u.GetOrgID(),
"Name": u.GetName(),
"Description": u.GetDescription(),
}
rows = append(rows, row)
}
return c.PrintTable(headers, rows...)
}
func (c Client) getOrgID(ctx context.Context, orgID influxid.ID, orgName string) (string, error) {
if orgID.Valid() {
return orgID.String(), nil
} else {
if orgName == "" {
orgName = c.ActiveConfig.Org
}
resp, err := c.GetOrgs(ctx).Org(orgName).Execute()
if err != nil {
return "", fmt.Errorf("failed to lookup ID of org %q: %w", orgName, err)
}
orgs := resp.GetOrgs()
if len(orgs) == 0 {
return "", fmt.Errorf("no organization found with name %q", orgName)
}
return orgs[0].GetId(), nil
}
}

View File

@ -45,6 +45,7 @@ var app = cli.App{
newUserCmd(),
newTaskCommand(),
newBackupCmd(),
newTelegrafsCommand(),
},
}

238
cmd/influx/telegrafs.go Normal file
View File

@ -0,0 +1,238 @@
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/influxdata/influx-cli/v2/clients/telegrafs"
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
"github.com/urfave/cli/v2"
)
func newTelegrafsCommand() *cli.Command {
var params telegrafs.ListParams
flags := append(commonFlags(), getOrgFlags(&params.OrgParams)...)
flags = append(flags, &cli.StringFlag{
Name: "id",
Usage: "Telegraf configuration ID to retrieve",
Aliases: []string{"i"},
Destination: &params.Id,
})
return &cli.Command{
Name: "telegrafs",
Usage: "List Telegraf configuration(s). Subcommands manage Telegraf configurations.",
Description: `List Telegraf configuration(s). Subcommands manage Telegraf configurations.
Examples:
# list all known Telegraf configurations
influx telegrafs
# list Telegraf configuration corresponding to specific ID
influx telegrafs --id $ID
# list Telegraf configuration corresponding to specific ID shorts
influx telegrafs -i $ID
`,
Subcommands: []*cli.Command{
newCreateTelegrafCmd(),
newRemoveTelegrafCmd(),
newUpdateTelegrafCmd(),
},
Flags: flags,
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
Action: func(ctx *cli.Context) error {
api := getAPI(ctx)
client := telegrafs.Client{
CLI: getCLI(ctx),
TelegrafsApi: api.TelegrafsApi,
OrganizationsApi: api.OrganizationsApi,
}
return client.List(ctx.Context, &params)
},
}
}
func newCreateTelegrafCmd() *cli.Command {
var params telegrafs.CreateParams
flags := append(commonFlags(), getOrgFlags(&params.OrgParams)...)
flags = append(flags,
&cli.StringFlag{
Name: "description",
Usage: "Description for Telegraf configuration",
Aliases: []string{"d"},
Destination: &params.Desc,
},
&cli.StringFlag{
Name: "file",
Usage: "Path to Telegraf configuration",
Aliases: []string{"f"},
},
&cli.StringFlag{
Name: "name",
Usage: "Name of Telegraf configuration",
Aliases: []string{"n"},
Destination: &params.Name,
},
)
return &cli.Command{
Name: "create",
Usage: "The telegrafs create command creates a new Telegraf configuration.",
Description: `The telegrafs create command creates a new Telegraf configuration.
Examples:
# create new Telegraf configuration
influx telegrafs create --name $CFG_NAME --description $CFG_DESC --file $PATH_TO_TELE_CFG
# create new Telegraf configuration using shorts
influx telegrafs create -n $CFG_NAME -d $CFG_DESC -f $PATH_TO_TELE_CFG
# create a new Telegraf config with a config provided via STDIN
cat $CONFIG_FILE | influx telegrafs create -n $CFG_NAME -d $CFG_DESC
`,
Flags: flags,
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
Action: func(ctx *cli.Context) error {
conf, err := readConfig(ctx.String("file"))
if err != nil {
return err
}
params.Config = conf
api := getAPI(ctx)
client := telegrafs.Client{
CLI: getCLI(ctx),
TelegrafsApi: api.TelegrafsApi,
OrganizationsApi: api.OrganizationsApi,
}
return client.Create(ctx.Context, &params)
},
}
}
func newRemoveTelegrafCmd() *cli.Command {
var params telegrafs.RemoveParams
flags := commonFlags()
flags = append(flags,
&cli.StringSliceFlag{
Name: "id",
Usage: "Telegraf configuration ID(s) to remove",
Aliases: []string{"i"},
},
&cli.StringFlag{Name: "org", Hidden: true},
&cli.StringFlag{Name: "org-id", Hidden: true},
)
return &cli.Command{
Name: "rm",
Usage: "The telegrafs rm command removes Telegraf configuration(s).",
Description: `The telegrafs rm command removes Telegraf configuration(s).
Examples:
# remove a single Telegraf configuration
influx telegrafs rm --id $ID
# remove multiple Telegraf configurations
influx telegrafs rm --id $ID1 --id $ID2
# remove using short flags
influx telegrafs rm -i $ID1
`,
Aliases: []string{"remove"},
Flags: flags,
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
Action: func(ctx *cli.Context) error {
rawIds := ctx.StringSlice("id")
params.Ids = rawIds
api := getAPI(ctx)
client := telegrafs.Client{
CLI: getCLI(ctx),
TelegrafsApi: api.TelegrafsApi,
OrganizationsApi: api.OrganizationsApi,
}
return client.Remove(ctx.Context, &params)
},
}
}
func newUpdateTelegrafCmd() *cli.Command {
var params telegrafs.UpdateParams
flags := commonFlags()
flags = append(flags,
&cli.StringFlag{
Name: "description",
Usage: "Description for Telegraf configuration",
Aliases: []string{"d"},
Destination: &params.Desc,
},
&cli.StringFlag{
Name: "file",
Usage: "Path to Telegraf configuration",
Aliases: []string{"f"},
},
&cli.StringFlag{
Name: "name",
Usage: "Name of Telegraf configuration",
Aliases: []string{"n"},
Destination: &params.Name,
},
&cli.StringFlag{
Name: "id",
Usage: "Telegraf configuration ID to retrieve",
Aliases: []string{"i"},
Destination: &params.Id,
},
&cli.StringFlag{Name: "org", Hidden: true},
&cli.StringFlag{Name: "org-id", Hidden: true},
)
return &cli.Command{
Name: "update",
Usage: "Update a Telegraf configuration.",
Description: `The telegrafs update command updates a Telegraf configuration to match the
specified parameters. If a name or description is not provided, then are set
to an empty string.
Examples:
# update new Telegraf configuration
influx telegrafs update --id $ID --name $CFG_NAME --description $CFG_DESC --file $PATH_TO_TELE_CFG
# update new Telegraf configuration using shorts
influx telegrafs update -i $ID -n $CFG_NAME -d $CFG_DESC -f $PATH_TO_TELE_CFG
# update a Telegraf config with a config provided via STDIN
cat $CONFIG_FILE | influx telegrafs update -i $ID -n $CFG_NAME -d $CFG_DESC
`,
Flags: flags,
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
Action: func(ctx *cli.Context) error {
conf, err := readConfig(ctx.String("file"))
if err != nil {
return err
}
params.Config = conf
api := getAPI(ctx)
client := telegrafs.Client{
CLI: getCLI(ctx),
TelegrafsApi: api.TelegrafsApi,
OrganizationsApi: api.OrganizationsApi,
}
return client.Update(ctx.Context, &params)
},
}
}
func readConfig(file string) (string, error) {
if file != "" {
bb, err := ioutil.ReadFile(file)
if err != nil {
return "", fmt.Errorf("failed to read telegraf config from %q: %w", file, err)
}
return string(bb), nil
}
bb, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return "", fmt.Errorf("failed to read telegraf config from stdin: %w", err)
}
return string(bb), nil
}