diff --git a/api/api_backup.gen.go b/api/api_backup.gen.go index 13bbe91..7a526c2 100644 --- a/api/api_backup.gen.go +++ b/api/api_backup.gen.go @@ -28,7 +28,7 @@ var ( type BackupApi interface { /* - * GetBackupKV Download snapshot of metadata stored in the server's embedded KV store. Should not be used in versions > 2.1.x, as it doesn't include metadata stored in embedded SQL. + * GetBackupKV Download snapshot of metadata stored in the server's embedded KV store. Should not be used in versions greater than 2.1.x, as it doesn't include metadata stored in embedded SQL. * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @return ApiGetBackupKVRequest */ @@ -110,7 +110,7 @@ func (r ApiGetBackupKVRequest) Execute() (*_nethttp.Response, error) { } /* - * GetBackupKV Download snapshot of metadata stored in the server's embedded KV store. Should not be used in versions > 2.1.x, as it doesn't include metadata stored in embedded SQL. + * GetBackupKV Download snapshot of metadata stored in the server's embedded KV store. Should not be used in versions greater than 2.1.x, as it doesn't include metadata stored in embedded SQL. * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @return ApiGetBackupKVRequest */ diff --git a/api/api_remote_connections.gen.go b/api/api_remote_connections.gen.go new file mode 100644 index 0000000..0abc04c --- /dev/null +++ b/api/api_remote_connections.gen.go @@ -0,0 +1,1143 @@ +/* + * 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" + _fmt "fmt" + _io "io" + _nethttp "net/http" + _neturl "net/url" + "strings" +) + +// Linger please +var ( + _ _context.Context +) + +type RemoteConnectionsApi interface { + + /* + * DeleteRemoteConnectionByID Delete a remote connection + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param remoteID + * @return ApiDeleteRemoteConnectionByIDRequest + */ + DeleteRemoteConnectionByID(ctx _context.Context, remoteID string) ApiDeleteRemoteConnectionByIDRequest + + /* + * DeleteRemoteConnectionByIDExecute executes the request + */ + DeleteRemoteConnectionByIDExecute(r ApiDeleteRemoteConnectionByIDRequest) error + + /* + * GetRemoteConnectionByID Retrieve a remote connection + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param remoteID + * @return ApiGetRemoteConnectionByIDRequest + */ + GetRemoteConnectionByID(ctx _context.Context, remoteID string) ApiGetRemoteConnectionByIDRequest + + /* + * GetRemoteConnectionByIDExecute executes the request + * @return RemoteConnection + */ + GetRemoteConnectionByIDExecute(r ApiGetRemoteConnectionByIDRequest) (RemoteConnection, error) + + /* + * GetRemoteConnections List all remote connections + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return ApiGetRemoteConnectionsRequest + */ + GetRemoteConnections(ctx _context.Context) ApiGetRemoteConnectionsRequest + + /* + * GetRemoteConnectionsExecute executes the request + * @return RemoteConnections + */ + GetRemoteConnectionsExecute(r ApiGetRemoteConnectionsRequest) (RemoteConnections, error) + + /* + * PatchRemoteConnectionByID Update a remote connection + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param remoteID + * @return ApiPatchRemoteConnectionByIDRequest + */ + PatchRemoteConnectionByID(ctx _context.Context, remoteID string) ApiPatchRemoteConnectionByIDRequest + + /* + * PatchRemoteConnectionByIDExecute executes the request + * @return RemoteConnection + */ + PatchRemoteConnectionByIDExecute(r ApiPatchRemoteConnectionByIDRequest) (RemoteConnection, error) + + /* + * PostRemoteConnection Register a new remote connection + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return ApiPostRemoteConnectionRequest + */ + PostRemoteConnection(ctx _context.Context) ApiPostRemoteConnectionRequest + + /* + * PostRemoteConnectionExecute executes the request + * @return RemoteConnection + */ + PostRemoteConnectionExecute(r ApiPostRemoteConnectionRequest) (RemoteConnection, error) + + /* + * PostValidateRemoteConnectionByID Validate a remote connection + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param remoteID + * @return ApiPostValidateRemoteConnectionByIDRequest + */ + PostValidateRemoteConnectionByID(ctx _context.Context, remoteID string) ApiPostValidateRemoteConnectionByIDRequest + + /* + * PostValidateRemoteConnectionByIDExecute executes the request + */ + PostValidateRemoteConnectionByIDExecute(r ApiPostValidateRemoteConnectionByIDRequest) error + + // Sets additional descriptive text in the error message if any request in + // this API fails, indicating that it is intended to be used only on OSS + // servers. + OnlyOSS() RemoteConnectionsApi + + // Sets additional descriptive text in the error message if any request in + // this API fails, indicating that it is intended to be used only on cloud + // servers. + OnlyCloud() RemoteConnectionsApi +} + +// RemoteConnectionsApiService RemoteConnectionsApi service +type RemoteConnectionsApiService service + +func (a *RemoteConnectionsApiService) OnlyOSS() RemoteConnectionsApi { + a.isOnlyOSS = true + return a +} + +func (a *RemoteConnectionsApiService) OnlyCloud() RemoteConnectionsApi { + a.isOnlyCloud = true + return a +} + +type ApiDeleteRemoteConnectionByIDRequest struct { + ctx _context.Context + ApiService RemoteConnectionsApi + remoteID string + zapTraceSpan *string +} + +func (r ApiDeleteRemoteConnectionByIDRequest) RemoteID(remoteID string) ApiDeleteRemoteConnectionByIDRequest { + r.remoteID = remoteID + return r +} +func (r ApiDeleteRemoteConnectionByIDRequest) GetRemoteID() string { + return r.remoteID +} + +func (r ApiDeleteRemoteConnectionByIDRequest) ZapTraceSpan(zapTraceSpan string) ApiDeleteRemoteConnectionByIDRequest { + r.zapTraceSpan = &zapTraceSpan + return r +} +func (r ApiDeleteRemoteConnectionByIDRequest) GetZapTraceSpan() *string { + return r.zapTraceSpan +} + +func (r ApiDeleteRemoteConnectionByIDRequest) Execute() error { + return r.ApiService.DeleteRemoteConnectionByIDExecute(r) +} + +/* + * DeleteRemoteConnectionByID Delete a remote connection + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param remoteID + * @return ApiDeleteRemoteConnectionByIDRequest + */ +func (a *RemoteConnectionsApiService) DeleteRemoteConnectionByID(ctx _context.Context, remoteID string) ApiDeleteRemoteConnectionByIDRequest { + return ApiDeleteRemoteConnectionByIDRequest{ + ApiService: a, + ctx: ctx, + remoteID: remoteID, + } +} + +/* + * Execute executes the request + */ +func (a *RemoteConnectionsApiService) DeleteRemoteConnectionByIDExecute(r ApiDeleteRemoteConnectionByIDRequest) error { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RemoteConnectionsApiService.DeleteRemoteConnectionByID") + if err != nil { + return GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/remotes/{remoteID}" + localVarPath = strings.Replace(localVarPath, "{"+"remoteID"+"}", _neturl.PathEscape(parameterToString(r.remoteID, "")), -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 + } + + var errorPrefix string + if a.isOnlyOSS { + errorPrefix = "InfluxDB OSS-only command failed: " + } else if a.isOnlyCloud { + errorPrefix = "InfluxDB Cloud-only command failed: " + } + + if localVarHTTPResponse.StatusCode >= 300 { + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + return _fmt.Errorf("%s%w", errorPrefix, err) + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + return _fmt.Errorf("%s%w", errorPrefix, err) + } + newErr := GenericOpenAPIError{ + body: localVarBody, + error: _fmt.Sprintf("%s%s", errorPrefix, localVarHTTPResponse.Status), + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return newErr + } + + return nil +} + +type ApiGetRemoteConnectionByIDRequest struct { + ctx _context.Context + ApiService RemoteConnectionsApi + remoteID string + zapTraceSpan *string +} + +func (r ApiGetRemoteConnectionByIDRequest) RemoteID(remoteID string) ApiGetRemoteConnectionByIDRequest { + r.remoteID = remoteID + return r +} +func (r ApiGetRemoteConnectionByIDRequest) GetRemoteID() string { + return r.remoteID +} + +func (r ApiGetRemoteConnectionByIDRequest) ZapTraceSpan(zapTraceSpan string) ApiGetRemoteConnectionByIDRequest { + r.zapTraceSpan = &zapTraceSpan + return r +} +func (r ApiGetRemoteConnectionByIDRequest) GetZapTraceSpan() *string { + return r.zapTraceSpan +} + +func (r ApiGetRemoteConnectionByIDRequest) Execute() (RemoteConnection, error) { + return r.ApiService.GetRemoteConnectionByIDExecute(r) +} + +/* + * GetRemoteConnectionByID Retrieve a remote connection + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param remoteID + * @return ApiGetRemoteConnectionByIDRequest + */ +func (a *RemoteConnectionsApiService) GetRemoteConnectionByID(ctx _context.Context, remoteID string) ApiGetRemoteConnectionByIDRequest { + return ApiGetRemoteConnectionByIDRequest{ + ApiService: a, + ctx: ctx, + remoteID: remoteID, + } +} + +/* + * Execute executes the request + * @return RemoteConnection + */ +func (a *RemoteConnectionsApiService) GetRemoteConnectionByIDExecute(r ApiGetRemoteConnectionByIDRequest) (RemoteConnection, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue RemoteConnection + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RemoteConnectionsApiService.GetRemoteConnectionByID") + if err != nil { + return localVarReturnValue, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/remotes/{remoteID}" + localVarPath = strings.Replace(localVarPath, "{"+"remoteID"+"}", _neturl.PathEscape(parameterToString(r.remoteID, "")), -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 localVarReturnValue, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + var errorPrefix string + if a.isOnlyOSS { + errorPrefix = "InfluxDB OSS-only command failed: " + } else if a.isOnlyCloud { + errorPrefix = "InfluxDB Cloud-only command failed: " + } + + if localVarHTTPResponse.StatusCode >= 300 { + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + newErr := GenericOpenAPIError{ + body: localVarBody, + error: _fmt.Sprintf("%s%s", errorPrefix, localVarHTTPResponse.Status), + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, newErr + } + + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: _fmt.Sprintf("%s%s", errorPrefix, err.Error()), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiGetRemoteConnectionsRequest struct { + ctx _context.Context + ApiService RemoteConnectionsApi + orgID *string + zapTraceSpan *string + name *string + remoteURL *string +} + +func (r ApiGetRemoteConnectionsRequest) OrgID(orgID string) ApiGetRemoteConnectionsRequest { + r.orgID = &orgID + return r +} +func (r ApiGetRemoteConnectionsRequest) GetOrgID() *string { + return r.orgID +} + +func (r ApiGetRemoteConnectionsRequest) ZapTraceSpan(zapTraceSpan string) ApiGetRemoteConnectionsRequest { + r.zapTraceSpan = &zapTraceSpan + return r +} +func (r ApiGetRemoteConnectionsRequest) GetZapTraceSpan() *string { + return r.zapTraceSpan +} + +func (r ApiGetRemoteConnectionsRequest) Name(name string) ApiGetRemoteConnectionsRequest { + r.name = &name + return r +} +func (r ApiGetRemoteConnectionsRequest) GetName() *string { + return r.name +} + +func (r ApiGetRemoteConnectionsRequest) RemoteURL(remoteURL string) ApiGetRemoteConnectionsRequest { + r.remoteURL = &remoteURL + return r +} +func (r ApiGetRemoteConnectionsRequest) GetRemoteURL() *string { + return r.remoteURL +} + +func (r ApiGetRemoteConnectionsRequest) Execute() (RemoteConnections, error) { + return r.ApiService.GetRemoteConnectionsExecute(r) +} + +/* + * GetRemoteConnections List all remote connections + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return ApiGetRemoteConnectionsRequest + */ +func (a *RemoteConnectionsApiService) GetRemoteConnections(ctx _context.Context) ApiGetRemoteConnectionsRequest { + return ApiGetRemoteConnectionsRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return RemoteConnections + */ +func (a *RemoteConnectionsApiService) GetRemoteConnectionsExecute(r ApiGetRemoteConnectionsRequest) (RemoteConnections, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue RemoteConnections + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RemoteConnectionsApiService.GetRemoteConnections") + if err != nil { + return localVarReturnValue, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/remotes" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.orgID == nil { + return localVarReturnValue, reportError("orgID is required and must be specified") + } + + localVarQueryParams.Add("orgID", parameterToString(*r.orgID, "")) + if r.name != nil { + localVarQueryParams.Add("name", parameterToString(*r.name, "")) + } + if r.remoteURL != nil { + localVarQueryParams.Add("remoteURL", parameterToString(*r.remoteURL, "")) + } + // 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 + } + + var errorPrefix string + if a.isOnlyOSS { + errorPrefix = "InfluxDB OSS-only command failed: " + } else if a.isOnlyCloud { + errorPrefix = "InfluxDB Cloud-only command failed: " + } + + if localVarHTTPResponse.StatusCode >= 300 { + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + newErr := GenericOpenAPIError{ + body: localVarBody, + error: _fmt.Sprintf("%s%s", errorPrefix, localVarHTTPResponse.Status), + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, newErr + } + + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: _fmt.Sprintf("%s%s", errorPrefix, err.Error()), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiPatchRemoteConnectionByIDRequest struct { + ctx _context.Context + ApiService RemoteConnectionsApi + remoteID string + remoteConnenctionUpdateRequest *RemoteConnenctionUpdateRequest + zapTraceSpan *string + validate *bool +} + +func (r ApiPatchRemoteConnectionByIDRequest) RemoteID(remoteID string) ApiPatchRemoteConnectionByIDRequest { + r.remoteID = remoteID + return r +} +func (r ApiPatchRemoteConnectionByIDRequest) GetRemoteID() string { + return r.remoteID +} + +func (r ApiPatchRemoteConnectionByIDRequest) RemoteConnenctionUpdateRequest(remoteConnenctionUpdateRequest RemoteConnenctionUpdateRequest) ApiPatchRemoteConnectionByIDRequest { + r.remoteConnenctionUpdateRequest = &remoteConnenctionUpdateRequest + return r +} +func (r ApiPatchRemoteConnectionByIDRequest) GetRemoteConnenctionUpdateRequest() *RemoteConnenctionUpdateRequest { + return r.remoteConnenctionUpdateRequest +} + +func (r ApiPatchRemoteConnectionByIDRequest) ZapTraceSpan(zapTraceSpan string) ApiPatchRemoteConnectionByIDRequest { + r.zapTraceSpan = &zapTraceSpan + return r +} +func (r ApiPatchRemoteConnectionByIDRequest) GetZapTraceSpan() *string { + return r.zapTraceSpan +} + +func (r ApiPatchRemoteConnectionByIDRequest) Validate(validate bool) ApiPatchRemoteConnectionByIDRequest { + r.validate = &validate + return r +} +func (r ApiPatchRemoteConnectionByIDRequest) GetValidate() *bool { + return r.validate +} + +func (r ApiPatchRemoteConnectionByIDRequest) Execute() (RemoteConnection, error) { + return r.ApiService.PatchRemoteConnectionByIDExecute(r) +} + +/* + * PatchRemoteConnectionByID Update a remote connection + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param remoteID + * @return ApiPatchRemoteConnectionByIDRequest + */ +func (a *RemoteConnectionsApiService) PatchRemoteConnectionByID(ctx _context.Context, remoteID string) ApiPatchRemoteConnectionByIDRequest { + return ApiPatchRemoteConnectionByIDRequest{ + ApiService: a, + ctx: ctx, + remoteID: remoteID, + } +} + +/* + * Execute executes the request + * @return RemoteConnection + */ +func (a *RemoteConnectionsApiService) PatchRemoteConnectionByIDExecute(r ApiPatchRemoteConnectionByIDRequest) (RemoteConnection, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue RemoteConnection + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RemoteConnectionsApiService.PatchRemoteConnectionByID") + if err != nil { + return localVarReturnValue, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/remotes/{remoteID}" + localVarPath = strings.Replace(localVarPath, "{"+"remoteID"+"}", _neturl.PathEscape(parameterToString(r.remoteID, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.remoteConnenctionUpdateRequest == nil { + return localVarReturnValue, reportError("remoteConnenctionUpdateRequest is required and must be specified") + } + + if r.validate != nil { + localVarQueryParams.Add("validate", parameterToString(*r.validate, "")) + } + // 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.remoteConnenctionUpdateRequest + 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 + } + + var errorPrefix string + if a.isOnlyOSS { + errorPrefix = "InfluxDB OSS-only command failed: " + } else if a.isOnlyCloud { + errorPrefix = "InfluxDB Cloud-only command failed: " + } + + if localVarHTTPResponse.StatusCode >= 300 { + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + newErr := GenericOpenAPIError{ + body: localVarBody, + error: _fmt.Sprintf("%s%s", errorPrefix, localVarHTTPResponse.Status), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, newErr + } + + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: _fmt.Sprintf("%s%s", errorPrefix, err.Error()), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiPostRemoteConnectionRequest struct { + ctx _context.Context + ApiService RemoteConnectionsApi + remoteConnectionCreationRequest *RemoteConnectionCreationRequest + zapTraceSpan *string + validate *bool +} + +func (r ApiPostRemoteConnectionRequest) RemoteConnectionCreationRequest(remoteConnectionCreationRequest RemoteConnectionCreationRequest) ApiPostRemoteConnectionRequest { + r.remoteConnectionCreationRequest = &remoteConnectionCreationRequest + return r +} +func (r ApiPostRemoteConnectionRequest) GetRemoteConnectionCreationRequest() *RemoteConnectionCreationRequest { + return r.remoteConnectionCreationRequest +} + +func (r ApiPostRemoteConnectionRequest) ZapTraceSpan(zapTraceSpan string) ApiPostRemoteConnectionRequest { + r.zapTraceSpan = &zapTraceSpan + return r +} +func (r ApiPostRemoteConnectionRequest) GetZapTraceSpan() *string { + return r.zapTraceSpan +} + +func (r ApiPostRemoteConnectionRequest) Validate(validate bool) ApiPostRemoteConnectionRequest { + r.validate = &validate + return r +} +func (r ApiPostRemoteConnectionRequest) GetValidate() *bool { + return r.validate +} + +func (r ApiPostRemoteConnectionRequest) Execute() (RemoteConnection, error) { + return r.ApiService.PostRemoteConnectionExecute(r) +} + +/* + * PostRemoteConnection Register a new remote connection + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return ApiPostRemoteConnectionRequest + */ +func (a *RemoteConnectionsApiService) PostRemoteConnection(ctx _context.Context) ApiPostRemoteConnectionRequest { + return ApiPostRemoteConnectionRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return RemoteConnection + */ +func (a *RemoteConnectionsApiService) PostRemoteConnectionExecute(r ApiPostRemoteConnectionRequest) (RemoteConnection, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue RemoteConnection + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RemoteConnectionsApiService.PostRemoteConnection") + if err != nil { + return localVarReturnValue, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/remotes" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.remoteConnectionCreationRequest == nil { + return localVarReturnValue, reportError("remoteConnectionCreationRequest is required and must be specified") + } + + if r.validate != nil { + localVarQueryParams.Add("validate", parameterToString(*r.validate, "")) + } + // 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.remoteConnectionCreationRequest + 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 + } + + var errorPrefix string + if a.isOnlyOSS { + errorPrefix = "InfluxDB OSS-only command failed: " + } else if a.isOnlyCloud { + errorPrefix = "InfluxDB Cloud-only command failed: " + } + + if localVarHTTPResponse.StatusCode >= 300 { + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + newErr := GenericOpenAPIError{ + body: localVarBody, + error: _fmt.Sprintf("%s%s", errorPrefix, localVarHTTPResponse.Status), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return localVarReturnValue, newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return localVarReturnValue, newErr + } + + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + return localVarReturnValue, _fmt.Errorf("%s%w", errorPrefix, err) + } + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: _fmt.Sprintf("%s%s", errorPrefix, err.Error()), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +type ApiPostValidateRemoteConnectionByIDRequest struct { + ctx _context.Context + ApiService RemoteConnectionsApi + remoteID string + zapTraceSpan *string +} + +func (r ApiPostValidateRemoteConnectionByIDRequest) RemoteID(remoteID string) ApiPostValidateRemoteConnectionByIDRequest { + r.remoteID = remoteID + return r +} +func (r ApiPostValidateRemoteConnectionByIDRequest) GetRemoteID() string { + return r.remoteID +} + +func (r ApiPostValidateRemoteConnectionByIDRequest) ZapTraceSpan(zapTraceSpan string) ApiPostValidateRemoteConnectionByIDRequest { + r.zapTraceSpan = &zapTraceSpan + return r +} +func (r ApiPostValidateRemoteConnectionByIDRequest) GetZapTraceSpan() *string { + return r.zapTraceSpan +} + +func (r ApiPostValidateRemoteConnectionByIDRequest) Execute() error { + return r.ApiService.PostValidateRemoteConnectionByIDExecute(r) +} + +/* + * PostValidateRemoteConnectionByID Validate a remote connection + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param remoteID + * @return ApiPostValidateRemoteConnectionByIDRequest + */ +func (a *RemoteConnectionsApiService) PostValidateRemoteConnectionByID(ctx _context.Context, remoteID string) ApiPostValidateRemoteConnectionByIDRequest { + return ApiPostValidateRemoteConnectionByIDRequest{ + ApiService: a, + ctx: ctx, + remoteID: remoteID, + } +} + +/* + * Execute executes the request + */ +func (a *RemoteConnectionsApiService) PostValidateRemoteConnectionByIDExecute(r ApiPostValidateRemoteConnectionByIDRequest) error { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "RemoteConnectionsApiService.PostValidateRemoteConnectionByID") + if err != nil { + return GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/remotes/{remoteID}/validate" + localVarPath = strings.Replace(localVarPath, "{"+"remoteID"+"}", _neturl.PathEscape(parameterToString(r.remoteID, "")), -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 + } + + var errorPrefix string + if a.isOnlyOSS { + errorPrefix = "InfluxDB OSS-only command failed: " + } else if a.isOnlyCloud { + errorPrefix = "InfluxDB Cloud-only command failed: " + } + + if localVarHTTPResponse.StatusCode >= 300 { + body, err := GunzipIfNeeded(localVarHTTPResponse) + if err != nil { + body.Close() + return _fmt.Errorf("%s%w", errorPrefix, err) + } + localVarBody, err := _io.ReadAll(body) + body.Close() + if err != nil { + return _fmt.Errorf("%s%w", errorPrefix, err) + } + newErr := GenericOpenAPIError{ + body: localVarBody, + error: _fmt.Sprintf("%s%s", errorPrefix, localVarHTTPResponse.Status), + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return newErr + } + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = _fmt.Sprintf("%s: %s", newErr.Error(), err.Error()) + return newErr + } + v.SetMessage(_fmt.Sprintf("%s: %s", newErr.Error(), v.GetMessage())) + newErr.model = &v + return newErr + } + + return nil +} diff --git a/api/client.gen.go b/api/client.gen.go index 95c23eb..46e279b 100644 --- a/api/client.gen.go +++ b/api/client.gen.go @@ -68,6 +68,8 @@ type APIClient struct { QueryApi QueryApi + RemoteConnectionsApi RemoteConnectionsApi + RestoreApi RestoreApi SecretsApi SecretsApi @@ -116,6 +118,7 @@ func NewAPIClient(cfg *Configuration) *APIClient { c.LegacyAuthorizationsApi = (*LegacyAuthorizationsApiService)(&c.common) c.OrganizationsApi = (*OrganizationsApiService)(&c.common) c.QueryApi = (*QueryApiService)(&c.common) + c.RemoteConnectionsApi = (*RemoteConnectionsApiService)(&c.common) c.RestoreApi = (*RestoreApiService)(&c.common) c.SecretsApi = (*SecretsApiService)(&c.common) c.SetupApi = (*SetupApiService)(&c.common) diff --git a/api/contract/cli.yml b/api/contract/cli.yml index 8bdd507..af5a09a 100644 --- a/api/contract/cli.yml +++ b/api/contract/cli.yml @@ -107,6 +107,12 @@ paths: $ref: "./openapi/src/common/paths/authorizations.yml" /authorizations/{authID}: $ref: "./openapi/src/common/paths/authorizations_authID.yml" + /remotes: + $ref: "./openapi/src/oss/paths/remotes.yml" + /remotes/{remoteID}: + $ref: "./openapi/src/oss/paths/remotes_remoteID.yml" + /remotes/{remoteID}/validate: + $ref: "./openapi/src/oss/paths/remotes_remoteID_validate.yml" components: parameters: TraceSpan: @@ -417,3 +423,11 @@ components: $ref: "./openapi/src/oss/schemas/LegacyAuthorizationPostRequest.yml" AuthorizationPostRequest: $ref: "./openapi/src/common/schemas/AuthorizationPostRequest.yml" + RemoteConnection: + $ref: "./openapi/src/oss/schemas/RemoteConnection.yml" + RemoteConnectionCreationRequest: + $ref: "./openapi/src/oss/schemas/RemoteConnectionCreationRequest.yml" + RemoteConnenctionUpdateRequest: + $ref: "./openapi/src/oss/schemas/RemoteConnectionUpdateRequest.yml" + RemoteConnections: + $ref: "./openapi/src/oss/schemas/RemoteConnections.yml" diff --git a/api/contract/openapi b/api/contract/openapi index 20706d0..039f87e 160000 --- a/api/contract/openapi +++ b/api/contract/openapi @@ -1 +1 @@ -Subproject commit 20706d0876987520eb2c57cfc5364005ad4bcbed +Subproject commit 039f87e84d94f37cf286cedc66883e4a82a1805c diff --git a/api/model_remote_connection.gen.go b/api/model_remote_connection.gen.go new file mode 100644 index 0000000..aab451e --- /dev/null +++ b/api/model_remote_connection.gen.go @@ -0,0 +1,289 @@ +/* + * 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" +) + +// RemoteConnection struct for RemoteConnection +type RemoteConnection struct { + Id string `json:"id" yaml:"id"` + Name string `json:"name" yaml:"name"` + OrgID string `json:"orgID" yaml:"orgID"` + Description *string `json:"description,omitempty" yaml:"description,omitempty"` + RemoteURL string `json:"remoteURL" yaml:"remoteURL"` + RemoteOrgID string `json:"remoteOrgID" yaml:"remoteOrgID"` + AllowInsecureTLS bool `json:"allowInsecureTLS" yaml:"allowInsecureTLS"` +} + +// NewRemoteConnection instantiates a new RemoteConnection 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 NewRemoteConnection(id string, name string, orgID string, remoteURL string, remoteOrgID string, allowInsecureTLS bool) *RemoteConnection { + this := RemoteConnection{} + this.Id = id + this.Name = name + this.OrgID = orgID + this.RemoteURL = remoteURL + this.RemoteOrgID = remoteOrgID + this.AllowInsecureTLS = allowInsecureTLS + return &this +} + +// NewRemoteConnectionWithDefaults instantiates a new RemoteConnection 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 NewRemoteConnectionWithDefaults() *RemoteConnection { + this := RemoteConnection{} + var allowInsecureTLS bool = false + this.AllowInsecureTLS = allowInsecureTLS + return &this +} + +// GetId returns the Id field value +func (o *RemoteConnection) 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 *RemoteConnection) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value +func (o *RemoteConnection) SetId(v string) { + o.Id = v +} + +// GetName returns the Name field value +func (o *RemoteConnection) 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 *RemoteConnection) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *RemoteConnection) SetName(v string) { + o.Name = v +} + +// GetOrgID returns the OrgID field value +func (o *RemoteConnection) GetOrgID() string { + if o == nil { + var ret string + return ret + } + + return o.OrgID +} + +// GetOrgIDOk returns a tuple with the OrgID field value +// and a boolean to check if the value has been set. +func (o *RemoteConnection) GetOrgIDOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.OrgID, true +} + +// SetOrgID sets field value +func (o *RemoteConnection) SetOrgID(v string) { + o.OrgID = v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *RemoteConnection) 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 *RemoteConnection) 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 *RemoteConnection) 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 *RemoteConnection) SetDescription(v string) { + o.Description = &v +} + +// GetRemoteURL returns the RemoteURL field value +func (o *RemoteConnection) GetRemoteURL() string { + if o == nil { + var ret string + return ret + } + + return o.RemoteURL +} + +// GetRemoteURLOk returns a tuple with the RemoteURL field value +// and a boolean to check if the value has been set. +func (o *RemoteConnection) GetRemoteURLOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.RemoteURL, true +} + +// SetRemoteURL sets field value +func (o *RemoteConnection) SetRemoteURL(v string) { + o.RemoteURL = v +} + +// GetRemoteOrgID returns the RemoteOrgID field value +func (o *RemoteConnection) GetRemoteOrgID() string { + if o == nil { + var ret string + return ret + } + + return o.RemoteOrgID +} + +// GetRemoteOrgIDOk returns a tuple with the RemoteOrgID field value +// and a boolean to check if the value has been set. +func (o *RemoteConnection) GetRemoteOrgIDOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.RemoteOrgID, true +} + +// SetRemoteOrgID sets field value +func (o *RemoteConnection) SetRemoteOrgID(v string) { + o.RemoteOrgID = v +} + +// GetAllowInsecureTLS returns the AllowInsecureTLS field value +func (o *RemoteConnection) GetAllowInsecureTLS() bool { + if o == nil { + var ret bool + return ret + } + + return o.AllowInsecureTLS +} + +// GetAllowInsecureTLSOk returns a tuple with the AllowInsecureTLS field value +// and a boolean to check if the value has been set. +func (o *RemoteConnection) GetAllowInsecureTLSOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.AllowInsecureTLS, true +} + +// SetAllowInsecureTLS sets field value +func (o *RemoteConnection) SetAllowInsecureTLS(v bool) { + o.AllowInsecureTLS = v +} + +func (o RemoteConnection) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if true { + toSerialize["id"] = o.Id + } + if true { + toSerialize["name"] = o.Name + } + if true { + toSerialize["orgID"] = o.OrgID + } + if o.Description != nil { + toSerialize["description"] = o.Description + } + if true { + toSerialize["remoteURL"] = o.RemoteURL + } + if true { + toSerialize["remoteOrgID"] = o.RemoteOrgID + } + if true { + toSerialize["allowInsecureTLS"] = o.AllowInsecureTLS + } + return json.Marshal(toSerialize) +} + +type NullableRemoteConnection struct { + value *RemoteConnection + isSet bool +} + +func (v NullableRemoteConnection) Get() *RemoteConnection { + return v.value +} + +func (v *NullableRemoteConnection) Set(val *RemoteConnection) { + v.value = val + v.isSet = true +} + +func (v NullableRemoteConnection) IsSet() bool { + return v.isSet +} + +func (v *NullableRemoteConnection) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRemoteConnection(val *RemoteConnection) *NullableRemoteConnection { + return &NullableRemoteConnection{value: val, isSet: true} +} + +func (v NullableRemoteConnection) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRemoteConnection) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/model_remote_connection_creation_request.gen.go b/api/model_remote_connection_creation_request.gen.go new file mode 100644 index 0000000..dfcde92 --- /dev/null +++ b/api/model_remote_connection_creation_request.gen.go @@ -0,0 +1,289 @@ +/* + * 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" +) + +// RemoteConnectionCreationRequest struct for RemoteConnectionCreationRequest +type RemoteConnectionCreationRequest struct { + Name string `json:"name" yaml:"name"` + Description *string `json:"description,omitempty" yaml:"description,omitempty"` + OrgID string `json:"orgID" yaml:"orgID"` + RemoteURL string `json:"remoteURL" yaml:"remoteURL"` + RemoteAPIToken string `json:"remoteAPIToken" yaml:"remoteAPIToken"` + RemoteOrgID string `json:"remoteOrgID" yaml:"remoteOrgID"` + AllowInsecureTLS bool `json:"allowInsecureTLS" yaml:"allowInsecureTLS"` +} + +// NewRemoteConnectionCreationRequest instantiates a new RemoteConnectionCreationRequest 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 NewRemoteConnectionCreationRequest(name string, orgID string, remoteURL string, remoteAPIToken string, remoteOrgID string, allowInsecureTLS bool) *RemoteConnectionCreationRequest { + this := RemoteConnectionCreationRequest{} + this.Name = name + this.OrgID = orgID + this.RemoteURL = remoteURL + this.RemoteAPIToken = remoteAPIToken + this.RemoteOrgID = remoteOrgID + this.AllowInsecureTLS = allowInsecureTLS + return &this +} + +// NewRemoteConnectionCreationRequestWithDefaults instantiates a new RemoteConnectionCreationRequest 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 NewRemoteConnectionCreationRequestWithDefaults() *RemoteConnectionCreationRequest { + this := RemoteConnectionCreationRequest{} + var allowInsecureTLS bool = false + this.AllowInsecureTLS = allowInsecureTLS + return &this +} + +// GetName returns the Name field value +func (o *RemoteConnectionCreationRequest) 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 *RemoteConnectionCreationRequest) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *RemoteConnectionCreationRequest) SetName(v string) { + o.Name = v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *RemoteConnectionCreationRequest) 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 *RemoteConnectionCreationRequest) 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 *RemoteConnectionCreationRequest) 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 *RemoteConnectionCreationRequest) SetDescription(v string) { + o.Description = &v +} + +// GetOrgID returns the OrgID field value +func (o *RemoteConnectionCreationRequest) GetOrgID() string { + if o == nil { + var ret string + return ret + } + + return o.OrgID +} + +// GetOrgIDOk returns a tuple with the OrgID field value +// and a boolean to check if the value has been set. +func (o *RemoteConnectionCreationRequest) GetOrgIDOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.OrgID, true +} + +// SetOrgID sets field value +func (o *RemoteConnectionCreationRequest) SetOrgID(v string) { + o.OrgID = v +} + +// GetRemoteURL returns the RemoteURL field value +func (o *RemoteConnectionCreationRequest) GetRemoteURL() string { + if o == nil { + var ret string + return ret + } + + return o.RemoteURL +} + +// GetRemoteURLOk returns a tuple with the RemoteURL field value +// and a boolean to check if the value has been set. +func (o *RemoteConnectionCreationRequest) GetRemoteURLOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.RemoteURL, true +} + +// SetRemoteURL sets field value +func (o *RemoteConnectionCreationRequest) SetRemoteURL(v string) { + o.RemoteURL = v +} + +// GetRemoteAPIToken returns the RemoteAPIToken field value +func (o *RemoteConnectionCreationRequest) GetRemoteAPIToken() string { + if o == nil { + var ret string + return ret + } + + return o.RemoteAPIToken +} + +// GetRemoteAPITokenOk returns a tuple with the RemoteAPIToken field value +// and a boolean to check if the value has been set. +func (o *RemoteConnectionCreationRequest) GetRemoteAPITokenOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.RemoteAPIToken, true +} + +// SetRemoteAPIToken sets field value +func (o *RemoteConnectionCreationRequest) SetRemoteAPIToken(v string) { + o.RemoteAPIToken = v +} + +// GetRemoteOrgID returns the RemoteOrgID field value +func (o *RemoteConnectionCreationRequest) GetRemoteOrgID() string { + if o == nil { + var ret string + return ret + } + + return o.RemoteOrgID +} + +// GetRemoteOrgIDOk returns a tuple with the RemoteOrgID field value +// and a boolean to check if the value has been set. +func (o *RemoteConnectionCreationRequest) GetRemoteOrgIDOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.RemoteOrgID, true +} + +// SetRemoteOrgID sets field value +func (o *RemoteConnectionCreationRequest) SetRemoteOrgID(v string) { + o.RemoteOrgID = v +} + +// GetAllowInsecureTLS returns the AllowInsecureTLS field value +func (o *RemoteConnectionCreationRequest) GetAllowInsecureTLS() bool { + if o == nil { + var ret bool + return ret + } + + return o.AllowInsecureTLS +} + +// GetAllowInsecureTLSOk returns a tuple with the AllowInsecureTLS field value +// and a boolean to check if the value has been set. +func (o *RemoteConnectionCreationRequest) GetAllowInsecureTLSOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.AllowInsecureTLS, true +} + +// SetAllowInsecureTLS sets field value +func (o *RemoteConnectionCreationRequest) SetAllowInsecureTLS(v bool) { + o.AllowInsecureTLS = v +} + +func (o RemoteConnectionCreationRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if true { + toSerialize["name"] = o.Name + } + if o.Description != nil { + toSerialize["description"] = o.Description + } + if true { + toSerialize["orgID"] = o.OrgID + } + if true { + toSerialize["remoteURL"] = o.RemoteURL + } + if true { + toSerialize["remoteAPIToken"] = o.RemoteAPIToken + } + if true { + toSerialize["remoteOrgID"] = o.RemoteOrgID + } + if true { + toSerialize["allowInsecureTLS"] = o.AllowInsecureTLS + } + return json.Marshal(toSerialize) +} + +type NullableRemoteConnectionCreationRequest struct { + value *RemoteConnectionCreationRequest + isSet bool +} + +func (v NullableRemoteConnectionCreationRequest) Get() *RemoteConnectionCreationRequest { + return v.value +} + +func (v *NullableRemoteConnectionCreationRequest) Set(val *RemoteConnectionCreationRequest) { + v.value = val + v.isSet = true +} + +func (v NullableRemoteConnectionCreationRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableRemoteConnectionCreationRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRemoteConnectionCreationRequest(val *RemoteConnectionCreationRequest) *NullableRemoteConnectionCreationRequest { + return &NullableRemoteConnectionCreationRequest{value: val, isSet: true} +} + +func (v NullableRemoteConnectionCreationRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRemoteConnectionCreationRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/model_remote_connections.gen.go b/api/model_remote_connections.gen.go new file mode 100644 index 0000000..409bfe1 --- /dev/null +++ b/api/model_remote_connections.gen.go @@ -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" +) + +// RemoteConnections struct for RemoteConnections +type RemoteConnections struct { + Remotes *[]RemoteConnection `json:"remotes,omitempty" yaml:"remotes,omitempty"` +} + +// NewRemoteConnections instantiates a new RemoteConnections 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 NewRemoteConnections() *RemoteConnections { + this := RemoteConnections{} + return &this +} + +// NewRemoteConnectionsWithDefaults instantiates a new RemoteConnections 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 NewRemoteConnectionsWithDefaults() *RemoteConnections { + this := RemoteConnections{} + return &this +} + +// GetRemotes returns the Remotes field value if set, zero value otherwise. +func (o *RemoteConnections) GetRemotes() []RemoteConnection { + if o == nil || o.Remotes == nil { + var ret []RemoteConnection + return ret + } + return *o.Remotes +} + +// GetRemotesOk returns a tuple with the Remotes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RemoteConnections) GetRemotesOk() (*[]RemoteConnection, bool) { + if o == nil || o.Remotes == nil { + return nil, false + } + return o.Remotes, true +} + +// HasRemotes returns a boolean if a field has been set. +func (o *RemoteConnections) HasRemotes() bool { + if o != nil && o.Remotes != nil { + return true + } + + return false +} + +// SetRemotes gets a reference to the given []RemoteConnection and assigns it to the Remotes field. +func (o *RemoteConnections) SetRemotes(v []RemoteConnection) { + o.Remotes = &v +} + +func (o RemoteConnections) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Remotes != nil { + toSerialize["remotes"] = o.Remotes + } + return json.Marshal(toSerialize) +} + +type NullableRemoteConnections struct { + value *RemoteConnections + isSet bool +} + +func (v NullableRemoteConnections) Get() *RemoteConnections { + return v.value +} + +func (v *NullableRemoteConnections) Set(val *RemoteConnections) { + v.value = val + v.isSet = true +} + +func (v NullableRemoteConnections) IsSet() bool { + return v.isSet +} + +func (v *NullableRemoteConnections) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRemoteConnections(val *RemoteConnections) *NullableRemoteConnections { + return &NullableRemoteConnections{value: val, isSet: true} +} + +func (v NullableRemoteConnections) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRemoteConnections) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/model_remote_connenction_update_request.gen.go b/api/model_remote_connenction_update_request.gen.go new file mode 100644 index 0000000..9677c3f --- /dev/null +++ b/api/model_remote_connenction_update_request.gen.go @@ -0,0 +1,297 @@ +/* + * 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" +) + +// RemoteConnenctionUpdateRequest struct for RemoteConnenctionUpdateRequest +type RemoteConnenctionUpdateRequest struct { + Name *string `json:"name,omitempty" yaml:"name,omitempty"` + Description *string `json:"description,omitempty" yaml:"description,omitempty"` + RemoteURL *string `json:"remoteURL,omitempty" yaml:"remoteURL,omitempty"` + RemoteAPIToken *string `json:"remoteAPIToken,omitempty" yaml:"remoteAPIToken,omitempty"` + RemoteOrgID *string `json:"remoteOrgID,omitempty" yaml:"remoteOrgID,omitempty"` + AllowInsecureTLS *bool `json:"allowInsecureTLS,omitempty" yaml:"allowInsecureTLS,omitempty"` +} + +// NewRemoteConnenctionUpdateRequest instantiates a new RemoteConnenctionUpdateRequest 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 NewRemoteConnenctionUpdateRequest() *RemoteConnenctionUpdateRequest { + this := RemoteConnenctionUpdateRequest{} + var allowInsecureTLS bool = false + this.AllowInsecureTLS = &allowInsecureTLS + return &this +} + +// NewRemoteConnenctionUpdateRequestWithDefaults instantiates a new RemoteConnenctionUpdateRequest 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 NewRemoteConnenctionUpdateRequestWithDefaults() *RemoteConnenctionUpdateRequest { + this := RemoteConnenctionUpdateRequest{} + var allowInsecureTLS bool = false + this.AllowInsecureTLS = &allowInsecureTLS + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *RemoteConnenctionUpdateRequest) 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 *RemoteConnenctionUpdateRequest) 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 *RemoteConnenctionUpdateRequest) 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 *RemoteConnenctionUpdateRequest) SetName(v string) { + o.Name = &v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *RemoteConnenctionUpdateRequest) 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 *RemoteConnenctionUpdateRequest) 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 *RemoteConnenctionUpdateRequest) 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 *RemoteConnenctionUpdateRequest) SetDescription(v string) { + o.Description = &v +} + +// GetRemoteURL returns the RemoteURL field value if set, zero value otherwise. +func (o *RemoteConnenctionUpdateRequest) GetRemoteURL() string { + if o == nil || o.RemoteURL == nil { + var ret string + return ret + } + return *o.RemoteURL +} + +// GetRemoteURLOk returns a tuple with the RemoteURL field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RemoteConnenctionUpdateRequest) GetRemoteURLOk() (*string, bool) { + if o == nil || o.RemoteURL == nil { + return nil, false + } + return o.RemoteURL, true +} + +// HasRemoteURL returns a boolean if a field has been set. +func (o *RemoteConnenctionUpdateRequest) HasRemoteURL() bool { + if o != nil && o.RemoteURL != nil { + return true + } + + return false +} + +// SetRemoteURL gets a reference to the given string and assigns it to the RemoteURL field. +func (o *RemoteConnenctionUpdateRequest) SetRemoteURL(v string) { + o.RemoteURL = &v +} + +// GetRemoteAPIToken returns the RemoteAPIToken field value if set, zero value otherwise. +func (o *RemoteConnenctionUpdateRequest) GetRemoteAPIToken() string { + if o == nil || o.RemoteAPIToken == nil { + var ret string + return ret + } + return *o.RemoteAPIToken +} + +// GetRemoteAPITokenOk returns a tuple with the RemoteAPIToken field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RemoteConnenctionUpdateRequest) GetRemoteAPITokenOk() (*string, bool) { + if o == nil || o.RemoteAPIToken == nil { + return nil, false + } + return o.RemoteAPIToken, true +} + +// HasRemoteAPIToken returns a boolean if a field has been set. +func (o *RemoteConnenctionUpdateRequest) HasRemoteAPIToken() bool { + if o != nil && o.RemoteAPIToken != nil { + return true + } + + return false +} + +// SetRemoteAPIToken gets a reference to the given string and assigns it to the RemoteAPIToken field. +func (o *RemoteConnenctionUpdateRequest) SetRemoteAPIToken(v string) { + o.RemoteAPIToken = &v +} + +// GetRemoteOrgID returns the RemoteOrgID field value if set, zero value otherwise. +func (o *RemoteConnenctionUpdateRequest) GetRemoteOrgID() string { + if o == nil || o.RemoteOrgID == nil { + var ret string + return ret + } + return *o.RemoteOrgID +} + +// GetRemoteOrgIDOk returns a tuple with the RemoteOrgID field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RemoteConnenctionUpdateRequest) GetRemoteOrgIDOk() (*string, bool) { + if o == nil || o.RemoteOrgID == nil { + return nil, false + } + return o.RemoteOrgID, true +} + +// HasRemoteOrgID returns a boolean if a field has been set. +func (o *RemoteConnenctionUpdateRequest) HasRemoteOrgID() bool { + if o != nil && o.RemoteOrgID != nil { + return true + } + + return false +} + +// SetRemoteOrgID gets a reference to the given string and assigns it to the RemoteOrgID field. +func (o *RemoteConnenctionUpdateRequest) SetRemoteOrgID(v string) { + o.RemoteOrgID = &v +} + +// GetAllowInsecureTLS returns the AllowInsecureTLS field value if set, zero value otherwise. +func (o *RemoteConnenctionUpdateRequest) GetAllowInsecureTLS() bool { + if o == nil || o.AllowInsecureTLS == nil { + var ret bool + return ret + } + return *o.AllowInsecureTLS +} + +// GetAllowInsecureTLSOk returns a tuple with the AllowInsecureTLS field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RemoteConnenctionUpdateRequest) GetAllowInsecureTLSOk() (*bool, bool) { + if o == nil || o.AllowInsecureTLS == nil { + return nil, false + } + return o.AllowInsecureTLS, true +} + +// HasAllowInsecureTLS returns a boolean if a field has been set. +func (o *RemoteConnenctionUpdateRequest) HasAllowInsecureTLS() bool { + if o != nil && o.AllowInsecureTLS != nil { + return true + } + + return false +} + +// SetAllowInsecureTLS gets a reference to the given bool and assigns it to the AllowInsecureTLS field. +func (o *RemoteConnenctionUpdateRequest) SetAllowInsecureTLS(v bool) { + o.AllowInsecureTLS = &v +} + +func (o RemoteConnenctionUpdateRequest) 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.RemoteURL != nil { + toSerialize["remoteURL"] = o.RemoteURL + } + if o.RemoteAPIToken != nil { + toSerialize["remoteAPIToken"] = o.RemoteAPIToken + } + if o.RemoteOrgID != nil { + toSerialize["remoteOrgID"] = o.RemoteOrgID + } + if o.AllowInsecureTLS != nil { + toSerialize["allowInsecureTLS"] = o.AllowInsecureTLS + } + return json.Marshal(toSerialize) +} + +type NullableRemoteConnenctionUpdateRequest struct { + value *RemoteConnenctionUpdateRequest + isSet bool +} + +func (v NullableRemoteConnenctionUpdateRequest) Get() *RemoteConnenctionUpdateRequest { + return v.value +} + +func (v *NullableRemoteConnenctionUpdateRequest) Set(val *RemoteConnenctionUpdateRequest) { + v.value = val + v.isSet = true +} + +func (v NullableRemoteConnenctionUpdateRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableRemoteConnenctionUpdateRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRemoteConnenctionUpdateRequest(val *RemoteConnenctionUpdateRequest) *NullableRemoteConnenctionUpdateRequest { + return &NullableRemoteConnenctionUpdateRequest{value: val, isSet: true} +} + +func (v NullableRemoteConnenctionUpdateRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRemoteConnenctionUpdateRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/clients/remote/remote.go b/clients/remote/remote.go new file mode 100644 index 0000000..7f0c4d7 --- /dev/null +++ b/clients/remote/remote.go @@ -0,0 +1,117 @@ +package remote + +import ( + "context" + "fmt" + + "github.com/influxdata/influx-cli/v2/api" + "github.com/influxdata/influx-cli/v2/clients" +) + +type Client struct { + clients.CLI + api.RemoteConnectionsApi + api.OrganizationsApi +} + +type CreateParams struct { + Name string + Description string + OrgID string + OrgName string + RemoteURL string + RemoteAPIToken string + RemoteOrgID string + AllowInsecureTLS bool +} + +func (c Client) Create(ctx context.Context, params *CreateParams) error { + + if params.OrgID == "" && params.OrgName == "" && c.ActiveConfig.Org == "" { + return clients.ErrMustSpecifyOrg + } + + // get org id via org name + if params.OrgID == "" { + name := params.OrgName + if name == "" { + name = c.ActiveConfig.Org + } + res, err := c.GetOrgs(ctx).Org(name).Execute() + if err != nil { + return fmt.Errorf("failed to lookup ID of org %q: %w", name, err) + } + orgs := res.GetOrgs() + if len(orgs) == 0 { + return fmt.Errorf("no organization found with name %q", name) + } + params.OrgID = orgs[0].GetId() + } + + // set up a struct with required params + body := api.RemoteConnectionCreationRequest{ + Name: params.Name, + OrgID: params.OrgID, + RemoteURL: params.RemoteURL, + RemoteAPIToken: params.RemoteAPIToken, + RemoteOrgID: params.RemoteOrgID, + AllowInsecureTLS: params.AllowInsecureTLS, + } + + if params.Description != "" { + body.Description = ¶ms.Description + } + + // send post request + res, err := c.PostRemoteConnection(ctx).RemoteConnectionCreationRequest(body).Execute() + if err != nil { + return fmt.Errorf("failed to create remote connection %q: %w", params.Name, err) + } + // print confirmation of new connection + return c.printRemote(printRemoteOpts{remote: &res}) +} + +type printRemoteOpts struct { + remote *api.RemoteConnection + remotes []api.RemoteConnection + deleted bool +} + +func (c Client) printRemote(opts printRemoteOpts) error { + if c.PrintAsJSON { + var v interface{} + if opts.remote != nil { + v = opts.remote + } else { + v = opts.remotes + } + return c.PrintJSON(v) + } + + headers := []string{"ID", "Name", "Org ID", "Remote URL", "Remote Org ID", "Allow Insecure TLS"} + if opts.deleted { + headers = append(headers, "Deleted") + } + + if opts.remote != nil { + opts.remotes = append(opts.remotes, *opts.remote) + } + + var rows []map[string]interface{} + for _, r := range opts.remotes { + row := map[string]interface{}{ + "ID": r.GetId(), + "Name": r.GetName(), + "Org ID": r.OrgID, + "Remote URL": r.RemoteURL, + "Remote Org ID": r.RemoteOrgID, + "Allow Insecure TLS": r.AllowInsecureTLS, + } + if opts.deleted { + row["Deleted"] = true + } + rows = append(rows, row) + } + + return c.PrintTable(headers, rows...) +} diff --git a/cmd/influx/remote.go b/cmd/influx/remote.go index 0882570..d6254f2 100644 --- a/cmd/influx/remote.go +++ b/cmd/influx/remote.go @@ -3,6 +3,7 @@ package main import ( "fmt" + "github.com/influxdata/influx-cli/v2/clients/remote" "github.com/influxdata/influx-cli/v2/pkg/cli/middleware" "github.com/urfave/cli" ) @@ -22,13 +23,68 @@ func newRemoteCmd() cli.Command { } func newRemoteCreateCmd() cli.Command { + var params remote.CreateParams return cli.Command{ Name: "create", Usage: "Create a new remote connection", Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs), - Flags: commonFlags(), - Action: func(ctx *cli.Context) { - fmt.Println("remote create command was called") + Flags: append( + commonFlags(), + &cli.StringFlag{ + Name: "name, n", + Usage: "Name for the new remote connection", + Required: true, + Destination: ¶ms.Name, + }, + &cli.StringFlag{ + Name: "description, d", + Usage: "Description for the new remote connection", + Destination: ¶ms.Description, + }, + &cli.StringFlag{ + Name: "org-id", + Usage: "The ID of the local organization", + EnvVar: "INFLUX_ORG_ID", + Destination: ¶ms.OrgID, + }, + &cli.StringFlag{ + Name: "org, o", + Usage: "The name of the organization", + EnvVar: "INFLUX_ORG", + Destination: ¶ms.OrgName, + }, + &cli.StringFlag{ + Name: "remote-url", + Usage: "The url for the remote database", + Required: true, + Destination: ¶ms.RemoteURL, + }, + &cli.StringFlag{ + Name: "remote-api-token", + Usage: "The API token for the remote database", + Required: true, + Destination: ¶ms.RemoteAPIToken, + }, + &cli.StringFlag{ + Name: "remote-org-id", + Usage: "The ID of the remote organization", + Required: true, + Destination: ¶ms.RemoteOrgID, + }, + &cli.BoolFlag{ + Name: "allow-insecure-tls", + Usage: "Allows insecure TLS", + Destination: ¶ms.AllowInsecureTLS, + }, + ), + Action: func(ctx *cli.Context) error { + client := remote.Client{ + CLI: getCLI(ctx), + RemoteConnectionsApi: getAPI(ctx).RemoteConnectionsApi, + OrganizationsApi: getAPI(ctx).OrganizationsApi, + } + + return client.Create(getContext(ctx), ¶ms) }, } }