From d51fac2d553060df2178ad38372b5a8372dacc3a Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 25 Nov 2024 04:02:24 +0100 Subject: [PATCH 1/2] fix some badly named API endpoints # Conflicts: # pkg/instance/api_instance.go # schema.yml # web/src/pages/overview/cards/VersionCard.ts --- pkg/instance/api.go | 4 +- pkg/instance/api_instance.go | 37 ++++++--- pkg/instance/api_instance_test.go | 4 +- schema.yml | 80 ++++++++++--------- web/src/pages/overview/OverviewPage.ts | 4 +- .../overview/cards/CurrentInstanceCard.ts | 6 +- web/src/pages/overview/cards/VersionCard.ts | 29 +++++-- 7 files changed, 98 insertions(+), 66 deletions(-) diff --git a/pkg/instance/api.go b/pkg/instance/api.go index 00a85d19d..4deec089a 100644 --- a/pkg/instance/api.go +++ b/pkg/instance/api.go @@ -9,8 +9,8 @@ import ( func (i *Instance) setupInstanceAPI() { i.ForRole("instance", i.rootContext).AddEventListener(apitypes.EventTopicAPIMuxSetup, func(ev *roles.Event) { svc := ev.Payload.Data["svc"].(*web.Service) - svc.Get("/api/v1/cluster/instances", i.APIInstances()) - svc.Get("/api/v1/cluster/info", i.APIInstanceInfo()) + svc.Get("/api/v1/cluster", i.APIClusterInfo()) + svc.Get("/api/v1/cluster/instance", i.APIInstanceInfo()) svc.Post("/api/v1/cluster/roles/restart", i.APIClusterRoleRestart()) }) } diff --git a/pkg/instance/api_instance.go b/pkg/instance/api_instance.go index 75a57cf9a..b1159c0ad 100644 --- a/pkg/instance/api_instance.go +++ b/pkg/instance/api_instance.go @@ -6,6 +6,7 @@ import ( "strings" "beryju.io/gravity/pkg/extconfig" + "beryju.io/gravity/pkg/instance/migrate" "beryju.io/gravity/pkg/instance/types" "github.com/swaggest/usecase" "github.com/swaggest/usecase/status" @@ -13,12 +14,24 @@ import ( "go.uber.org/zap" ) -type APIInstancesOutput struct { - Instances []InstanceInfo `json:"instances" required:"true"` +type APIClusterInfoOutput struct { + ClusterVersion string `json:"clusterVersion" required:"true"` + ClusterVersionShort string `json:"clusterVersionShort" required:"true"` + Instances []InstanceInfo `json:"instances" required:"true"` } -func (i *Instance) APIInstances() usecase.Interactor { - u := usecase.NewInteractor(func(ctx context.Context, input struct{}, output *APIInstancesOutput) error { +func (i *Instance) APIClusterInfo() usecase.Interactor { + u := usecase.NewInteractor(func(ctx context.Context, input struct{}, output *APIClusterInfoOutput) error { + ri := i.ForRole("api", ctx) + m := migrate.New(ri) + cv, err := m.GetClusterVersion(ctx) + if err != nil { + return status.Internal + } + output.ClusterVersion = cv.String() + sv, _ := cv.SetMetadata("") + output.ClusterVersionShort = sv.String() + prefix := i.kv.Key(types.KeyInstance).Prefix(true).String() instances, err := i.kv.Get( ctx, @@ -44,9 +57,9 @@ func (i *Instance) APIInstances() usecase.Interactor { } return nil }) - u.SetName("cluster.get_instances") - u.SetTitle("Instances") - u.SetTags("cluster/instances") + u.SetName("cluster.get_cluster_info") + u.SetTitle("Cluster") + u.SetTags("cluster") u.SetExpectedErrors(status.Internal) return u } @@ -57,8 +70,8 @@ type APIInstanceInfo struct { Dirs *extconfig.ExtConfigDirs `json:"dirs" required:"true"` - CurrentInstanceIdentifier string `json:"currentInstanceIdentifier" required:"true"` - CurrentInstanceIP string `json:"currentInstanceIP" required:"true"` + InstanceIdentifier string `json:"instanceIdentifier" required:"true"` + InstanceIP string `json:"instanceIP" required:"true"` } func (i *Instance) APIInstanceInfo() usecase.Interactor { @@ -66,11 +79,11 @@ func (i *Instance) APIInstanceInfo() usecase.Interactor { output.Version = extconfig.Version output.BuildHash = extconfig.BuildHash output.Dirs = extconfig.Get().Dirs() - output.CurrentInstanceIP = extconfig.Get().Instance.IP - output.CurrentInstanceIdentifier = extconfig.Get().Instance.Identifier + output.InstanceIP = extconfig.Get().Instance.IP + output.InstanceIdentifier = extconfig.Get().Instance.Identifier return nil }) - u.SetName("cluster.get_info") + u.SetName("cluster.get_instance_info") u.SetTitle("Instance") u.SetTags("cluster/instances") u.SetExpectedErrors(status.Internal) diff --git a/pkg/instance/api_instance_test.go b/pkg/instance/api_instance_test.go index fff4ced78..4068b32f6 100644 --- a/pkg/instance/api_instance_test.go +++ b/pkg/instance/api_instance_test.go @@ -23,7 +23,7 @@ func TestAPIInstances(t *testing.T) { defer tests.Setup(t)() rootInst := instance.New() - var output instance.APIInstancesOutput - assert.NoError(t, rootInst.APIInstances().Interact(tests.Context(), struct{}{}, &output)) + var output instance.APIClusterInfoOutput + assert.NoError(t, rootInst.APIClusterInfo().Interact(tests.Context(), struct{}{}, &output)) assert.NotNil(t, output) } diff --git a/schema.yml b/schema.yml index 1fa5b1f9a..3ea4d2bc4 100644 --- a/schema.yml +++ b/schema.yml @@ -243,6 +243,25 @@ paths: summary: Backup status tags: - roles/backup + /api/v1/cluster: + get: + operationId: cluster.get_cluster_info + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/InstanceAPIClusterInfoOutput' + description: OK + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/RestErrResponse' + description: Internal Server Error + summary: Cluster + tags: + - cluster /api/v1/cluster/export: post: operationId: api.export @@ -287,9 +306,9 @@ paths: summary: Import Cluster tags: - roles/api - /api/v1/cluster/info: + /api/v1/cluster/instance: get: - operationId: cluster.get_info + operationId: cluster.get_instance_info responses: "200": content: @@ -306,25 +325,6 @@ paths: summary: Instance tags: - cluster/instances - /api/v1/cluster/instances: - get: - operationId: cluster.get_instances - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/InstanceAPIInstancesOutput' - description: OK - "500": - content: - application/json: - schema: - $ref: '#/components/schemas/RestErrResponse' - description: Internal Server Error - summary: Instances - tags: - - cluster/instances /api/v1/cluster/node/logs: get: operationId: api.get_log_messages @@ -2355,34 +2355,40 @@ components: tftpLocalDir: type: string type: object - InstanceAPIInstanceInfo: + InstanceAPIClusterInfoOutput: properties: - buildHash: + clusterVersion: type: string - currentInstanceIP: + clusterVersionShort: type: string - currentInstanceIdentifier: + instances: + items: + $ref: '#/components/schemas/InstanceInstanceInfo' + nullable: true + type: array + required: + - clusterVersion + - clusterVersionShort + - instances + type: object + InstanceAPIInstanceInfo: + properties: + buildHash: type: string dirs: $ref: '#/components/schemas/ExtconfigExtConfigDirs' + instanceIP: + type: string + instanceIdentifier: + type: string version: type: string required: - version - buildHash - dirs - - currentInstanceIdentifier - - currentInstanceIP - type: object - InstanceAPIInstancesOutput: - properties: - instances: - items: - $ref: '#/components/schemas/InstanceInstanceInfo' - nullable: true - type: array - required: - - instances + - instanceIdentifier + - instanceIP type: object InstanceAPIRoleRestartInput: properties: diff --git a/web/src/pages/overview/OverviewPage.ts b/web/src/pages/overview/OverviewPage.ts index 06d06e055..cf7c951df 100644 --- a/web/src/pages/overview/OverviewPage.ts +++ b/web/src/pages/overview/OverviewPage.ts @@ -58,10 +58,10 @@ export class OverviewPage extends AKElement {
-
+
-
+
diff --git a/web/src/pages/overview/cards/CurrentInstanceCard.ts b/web/src/pages/overview/cards/CurrentInstanceCard.ts index c91b8c4a1..647e04711 100644 --- a/web/src/pages/overview/cards/CurrentInstanceCard.ts +++ b/web/src/pages/overview/cards/CurrentInstanceCard.ts @@ -11,16 +11,16 @@ export class CurrentInstanceCard extends AdminStatusCard { - return new ClusterInstancesApi(DEFAULT_CONFIG).clusterGetInfo(); + return new ClusterInstancesApi(DEFAULT_CONFIG).clusterGetInstanceInfo(); } getStatus(data: InstanceAPIInstanceInfo): Promise { return Promise.resolve({ icon: "fa fa-check-circle pf-m-success", - message: html`${data.currentInstanceIP}`, + message: html`${data.instanceIP}`, }); } renderValue() { - return html`${this.value?.currentInstanceIdentifier}`; + return html`${this.value?.instanceIdentifier}`; } } diff --git a/web/src/pages/overview/cards/VersionCard.ts b/web/src/pages/overview/cards/VersionCard.ts index 098576703..1de2ed4af 100644 --- a/web/src/pages/overview/cards/VersionCard.ts +++ b/web/src/pages/overview/cards/VersionCard.ts @@ -1,4 +1,7 @@ -import { ClusterInstancesApi, InstanceAPIInstanceInfo } from "gravity-api"; +import { + ClusterApi, + InstanceAPIClusterInfoOutput, +} from "gravity-api"; import { TemplateResult, html } from "lit"; import { customElement } from "lit/decorators.js"; @@ -7,27 +10,37 @@ import { DEFAULT_CONFIG } from "../../../api/Config"; import { AdminStatus, AdminStatusCard } from "./AdminStatusCard"; @customElement("gravity-overview-card-version") -export class VersionCard extends AdminStatusCard { +export class VersionCard extends AdminStatusCard { header = "Version"; headerLink = "#/cluster/nodes"; - getPrimaryValue(): Promise { - return new ClusterInstancesApi(DEFAULT_CONFIG).clusterGetInfo(); + async getPrimaryValue(): Promise { + return await new ClusterApi(DEFAULT_CONFIG).clusterGetClusterInfo(); } - getStatus(value: InstanceAPIInstanceInfo): Promise { + getStatus(value: InstanceAPIClusterInfoOutput): Promise { + const matching = + value.instances?.filter((inst) => { + return inst.version === value.clusterVersion; + }).length === value.instances?.length; + if (!matching) { + return Promise.resolve({ + icon: "fa fa-exclamation-triangle pf-m-warning", + message: html`Mismatched version in cluster!`, + }); + } return Promise.resolve({ icon: "fa fa-check-circle pf-m-success", - message: html`${value?.buildHash.substring(0, 7)}`, + message: html`Matching versions across nodes.`, }); } renderValue(): TemplateResult { return html` - ${this.value?.version} + ${this.value?.clusterVersion} `; } } From c8f506d3e0e2fde34c8067d04f42ecaed16cf8c8 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 25 Nov 2024 04:10:03 +0100 Subject: [PATCH 2/2] update go api --- api/.openapi-generator/FILES | 17 +- api/README.md | 6 +- api/api/openapi.yaml | 110 +++++------ api/api_cluster.go | 130 +++++++++++++ api/api_cluster_instances.go | 128 +------------ api/client.go | 3 + api/docs/ClusterApi.md | 68 +++++++ api/docs/ClusterInstancesApi.md | 76 +------- api/docs/InstanceAPIClusterInfoOutput.md | 103 +++++++++++ api/docs/InstanceAPIInstanceInfo.md | 60 +++--- api/model_instance_api_cluster_info_output.go | 173 ++++++++++++++++++ api/model_instance_api_instance_info.go | 78 ++++---- api/test/api_cluster_test.go | 35 ++++ cmd/cli/cli_health.go | 2 +- 14 files changed, 667 insertions(+), 322 deletions(-) create mode 100644 api/api_cluster.go create mode 100644 api/docs/ClusterApi.md create mode 100644 api/docs/InstanceAPIClusterInfoOutput.md create mode 100644 api/model_instance_api_cluster_info_output.go create mode 100644 api/test/api_cluster_test.go diff --git a/api/.openapi-generator/FILES b/api/.openapi-generator/FILES index 23b95ba71..e8eb89a65 100644 --- a/api/.openapi-generator/FILES +++ b/api/.openapi-generator/FILES @@ -2,6 +2,7 @@ .travis.yml README.md api/openapi.yaml +api_cluster.go api_cluster_instances.go api_roles_api.go api_roles_backup.go @@ -52,6 +53,7 @@ docs/BackupAPIRoleConfigInput.md docs/BackupAPIRoleConfigOutput.md docs/BackupBackupStatus.md docs/BackupRoleConfig.md +docs/ClusterApi.md docs/ClusterInstancesApi.md docs/DhcpAPILease.md docs/DhcpAPILeaseInfo.md @@ -84,8 +86,8 @@ docs/DnsAPIZonesGetOutput.md docs/DnsAPIZonesPutInput.md docs/DnsRoleConfig.md docs/ExtconfigExtConfigDirs.md +docs/InstanceAPIClusterInfoOutput.md docs/InstanceAPIInstanceInfo.md -docs/InstanceAPIInstancesOutput.md docs/InstanceAPIRoleRestartInput.md docs/InstanceInstanceInfo.md docs/MonitoringAPIRoleConfigInput.md @@ -188,8 +190,8 @@ model_dns_api_zones_get_output.go model_dns_api_zones_put_input.go model_dns_role_config.go model_extconfig_ext_config_dirs.go +model_instance_api_cluster_info_output.go model_instance_api_instance_info.go -model_instance_api_instances_output.go model_instance_api_role_restart_input.go model_instance_instance_info.go model_monitoring_api_role_config_input.go @@ -212,14 +214,5 @@ model_types_api_metrics_role.go model_types_dhcp_option.go model_types_oidc_config.go response.go -test/api_cluster_instances_test.go -test/api_roles_api_test.go -test/api_roles_backup_test.go -test/api_roles_dhcp_test.go -test/api_roles_discovery_test.go -test/api_roles_dns_test.go -test/api_roles_etcd_test.go -test/api_roles_monitoring_test.go -test/api_roles_tftp_test.go -test/api_roles_tsdb_test.go +test/api_cluster_test.go utils.go diff --git a/api/README.md b/api/README.md index 1187a1af4..68b53b584 100644 --- a/api/README.md +++ b/api/README.md @@ -77,8 +77,8 @@ All URIs are relative to *http://localhost* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*ClusterInstancesApi* | [**ClusterGetInfo**](docs/ClusterInstancesApi.md#clustergetinfo) | **Get** /api/v1/cluster/info | Instance -*ClusterInstancesApi* | [**ClusterGetInstances**](docs/ClusterInstancesApi.md#clustergetinstances) | **Get** /api/v1/cluster/instances | Instances +*ClusterApi* | [**ClusterGetClusterInfo**](docs/ClusterApi.md#clustergetclusterinfo) | **Get** /api/v1/cluster | Cluster +*ClusterInstancesApi* | [**ClusterGetInstanceInfo**](docs/ClusterInstancesApi.md#clustergetinstanceinfo) | **Get** /api/v1/cluster/instance | Instance *ClusterInstancesApi* | [**ClusterInstanceRoleRestart**](docs/ClusterInstancesApi.md#clusterinstancerolerestart) | **Post** /api/v1/cluster/roles/restart | Instance roles *RolesApiApi* | [**ApiAuthConfig**](docs/RolesApiApi.md#apiauthconfig) | **Get** /api/v1/auth/config | API Users *RolesApiApi* | [**ApiDeleteTokens**](docs/RolesApiApi.md#apideletetokens) | **Delete** /api/v1/auth/tokens | Tokens @@ -213,8 +213,8 @@ Class | Method | HTTP request | Description - [DnsAPIZonesPutInput](docs/DnsAPIZonesPutInput.md) - [DnsRoleConfig](docs/DnsRoleConfig.md) - [ExtconfigExtConfigDirs](docs/ExtconfigExtConfigDirs.md) + - [InstanceAPIClusterInfoOutput](docs/InstanceAPIClusterInfoOutput.md) - [InstanceAPIInstanceInfo](docs/InstanceAPIInstanceInfo.md) - - [InstanceAPIInstancesOutput](docs/InstanceAPIInstancesOutput.md) - [InstanceAPIRoleRestartInput](docs/InstanceAPIRoleRestartInput.md) - [InstanceInstanceInfo](docs/InstanceInstanceInfo.md) - [MonitoringAPIRoleConfigInput](docs/MonitoringAPIRoleConfigInput.md) diff --git a/api/api/openapi.yaml b/api/api/openapi.yaml index 08243398c..fc64f8001 100644 --- a/api/api/openapi.yaml +++ b/api/api/openapi.yaml @@ -258,6 +258,25 @@ paths: summary: Backup status tags: - roles/backup + /api/v1/cluster: + get: + operationId: cluster.get_cluster_info + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/InstanceAPIClusterInfoOutput' + description: OK + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/RestErrResponse' + description: Internal Server Error + summary: Cluster + tags: + - cluster /api/v1/cluster/export: post: operationId: api.export @@ -302,9 +321,9 @@ paths: summary: Import Cluster tags: - roles/api - /api/v1/cluster/info: + /api/v1/cluster/instance: get: - operationId: cluster.get_info + operationId: cluster.get_instance_info responses: "200": content: @@ -321,25 +340,6 @@ paths: summary: Instance tags: - cluster/instances - /api/v1/cluster/instances: - get: - operationId: cluster.get_instances - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/InstanceAPIInstancesOutput' - description: OK - "500": - content: - application/json: - schema: - $ref: '#/components/schemas/RestErrResponse' - description: Internal Server Error - summary: Instances - tags: - - cluster/instances /api/v1/cluster/node/logs: get: operationId: api.get_log_messages @@ -3053,37 +3053,9 @@ components: tftpLocalDir: type: string type: object - InstanceAPIInstanceInfo: - example: - currentInstanceIdentifier: currentInstanceIdentifier - currentInstanceIP: currentInstanceIP - buildHash: buildHash - dirs: - backupDir: backupDir - etcdDir: etcdDir - certDir: certDir - tftpLocalDir: tftpLocalDir - version: version - properties: - buildHash: - type: string - currentInstanceIP: - type: string - currentInstanceIdentifier: - type: string - dirs: - $ref: '#/components/schemas/ExtconfigExtConfigDirs' - version: - type: string - required: - - buildHash - - currentInstanceIP - - currentInstanceIdentifier - - dirs - - version - type: object - InstanceAPIInstancesOutput: + InstanceAPIClusterInfoOutput: example: + clusterVersionShort: clusterVersionShort instances: - identifier: identifier ip: ip @@ -3097,15 +3069,51 @@ components: - roles - roles version: version + clusterVersion: clusterVersion properties: + clusterVersion: + type: string + clusterVersionShort: + type: string instances: items: $ref: '#/components/schemas/InstanceInstanceInfo' nullable: true type: array required: + - clusterVersion + - clusterVersionShort - instances type: object + InstanceAPIInstanceInfo: + example: + buildHash: buildHash + dirs: + backupDir: backupDir + etcdDir: etcdDir + certDir: certDir + tftpLocalDir: tftpLocalDir + instanceIdentifier: instanceIdentifier + version: version + instanceIP: instanceIP + properties: + buildHash: + type: string + dirs: + $ref: '#/components/schemas/ExtconfigExtConfigDirs' + instanceIP: + type: string + instanceIdentifier: + type: string + version: + type: string + required: + - buildHash + - dirs + - instanceIP + - instanceIdentifier + - version + type: object InstanceAPIRoleRestartInput: example: roleId: roleId diff --git a/api/api_cluster.go b/api/api_cluster.go new file mode 100644 index 000000000..e94ae5337 --- /dev/null +++ b/api/api_cluster.go @@ -0,0 +1,130 @@ +/* +gravity + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +API version: 0.16.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" +) + +// ClusterApiService ClusterApi service +type ClusterApiService service + +type ApiClusterGetClusterInfoRequest struct { + ctx context.Context + ApiService *ClusterApiService +} + +func (r ApiClusterGetClusterInfoRequest) Execute() (*InstanceAPIClusterInfoOutput, *http.Response, error) { + return r.ApiService.ClusterGetClusterInfoExecute(r) +} + +/* +ClusterGetClusterInfo Cluster + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiClusterGetClusterInfoRequest +*/ +func (a *ClusterApiService) ClusterGetClusterInfo(ctx context.Context) ApiClusterGetClusterInfoRequest { + return ApiClusterGetClusterInfoRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return InstanceAPIClusterInfoOutput +func (a *ClusterApiService) ClusterGetClusterInfoExecute(r ApiClusterGetClusterInfoRequest) (*InstanceAPIClusterInfoOutput, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *InstanceAPIClusterInfoOutput + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ClusterApiService.ClusterGetClusterInfo") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/cluster" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.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 + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 500 { + var v RestErrResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/api/api_cluster_instances.go b/api/api_cluster_instances.go index 3e9c94e20..c013ca8bb 100644 --- a/api/api_cluster_instances.go +++ b/api/api_cluster_instances.go @@ -21,23 +21,23 @@ import ( // ClusterInstancesApiService ClusterInstancesApi service type ClusterInstancesApiService service -type ApiClusterGetInfoRequest struct { +type ApiClusterGetInstanceInfoRequest struct { ctx context.Context ApiService *ClusterInstancesApiService } -func (r ApiClusterGetInfoRequest) Execute() (*InstanceAPIInstanceInfo, *http.Response, error) { - return r.ApiService.ClusterGetInfoExecute(r) +func (r ApiClusterGetInstanceInfoRequest) Execute() (*InstanceAPIInstanceInfo, *http.Response, error) { + return r.ApiService.ClusterGetInstanceInfoExecute(r) } /* -ClusterGetInfo Instance +ClusterGetInstanceInfo Instance @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiClusterGetInfoRequest + @return ApiClusterGetInstanceInfoRequest */ -func (a *ClusterInstancesApiService) ClusterGetInfo(ctx context.Context) ApiClusterGetInfoRequest { - return ApiClusterGetInfoRequest{ +func (a *ClusterInstancesApiService) ClusterGetInstanceInfo(ctx context.Context) ApiClusterGetInstanceInfoRequest { + return ApiClusterGetInstanceInfoRequest{ ApiService: a, ctx: ctx, } @@ -46,7 +46,7 @@ func (a *ClusterInstancesApiService) ClusterGetInfo(ctx context.Context) ApiClus // Execute executes the request // // @return InstanceAPIInstanceInfo -func (a *ClusterInstancesApiService) ClusterGetInfoExecute(r ApiClusterGetInfoRequest) (*InstanceAPIInstanceInfo, *http.Response, error) { +func (a *ClusterInstancesApiService) ClusterGetInstanceInfoExecute(r ApiClusterGetInstanceInfoRequest) (*InstanceAPIInstanceInfo, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} @@ -54,120 +54,12 @@ func (a *ClusterInstancesApiService) ClusterGetInfoExecute(r ApiClusterGetInfoRe localVarReturnValue *InstanceAPIInstanceInfo ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ClusterInstancesApiService.ClusterGetInfo") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ClusterInstancesApiService.ClusterGetInstanceInfo") if err != nil { return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } - localVarPath := localBasePath + "/api/v1/cluster/info" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.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 - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - if localVarHTTPResponse.StatusCode == 500 { - var v RestErrResponse - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiClusterGetInstancesRequest struct { - ctx context.Context - ApiService *ClusterInstancesApiService -} - -func (r ApiClusterGetInstancesRequest) Execute() (*InstanceAPIInstancesOutput, *http.Response, error) { - return r.ApiService.ClusterGetInstancesExecute(r) -} - -/* -ClusterGetInstances Instances - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiClusterGetInstancesRequest -*/ -func (a *ClusterInstancesApiService) ClusterGetInstances(ctx context.Context) ApiClusterGetInstancesRequest { - return ApiClusterGetInstancesRequest{ - ApiService: a, - ctx: ctx, - } -} - -// Execute executes the request -// -// @return InstanceAPIInstancesOutput -func (a *ClusterInstancesApiService) ClusterGetInstancesExecute(r ApiClusterGetInstancesRequest) (*InstanceAPIInstancesOutput, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *InstanceAPIInstancesOutput - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ClusterInstancesApiService.ClusterGetInstances") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/api/v1/cluster/instances" + localVarPath := localBasePath + "/api/v1/cluster/instance" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} diff --git a/api/client.go b/api/client.go index 926835a5a..d4ac7475d 100644 --- a/api/client.go +++ b/api/client.go @@ -48,6 +48,8 @@ type APIClient struct { // API Services + ClusterApi *ClusterApiService + ClusterInstancesApi *ClusterInstancesApiService RolesApiApi *RolesApiApiService @@ -85,6 +87,7 @@ func NewAPIClient(cfg *Configuration) *APIClient { c.common.client = c // API Services + c.ClusterApi = (*ClusterApiService)(&c.common) c.ClusterInstancesApi = (*ClusterInstancesApiService)(&c.common) c.RolesApiApi = (*RolesApiApiService)(&c.common) c.RolesBackupApi = (*RolesBackupApiService)(&c.common) diff --git a/api/docs/ClusterApi.md b/api/docs/ClusterApi.md new file mode 100644 index 000000000..f4d6821f7 --- /dev/null +++ b/api/docs/ClusterApi.md @@ -0,0 +1,68 @@ +# \ClusterApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**ClusterGetClusterInfo**](ClusterApi.md#ClusterGetClusterInfo) | **Get** /api/v1/cluster | Cluster + + + +## ClusterGetClusterInfo + +> InstanceAPIClusterInfoOutput ClusterGetClusterInfo(ctx).Execute() + +Cluster + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "beryju.io/gravity/api" +) + +func main() { + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.ClusterApi.ClusterGetClusterInfo(context.Background()).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ClusterApi.ClusterGetClusterInfo``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `ClusterGetClusterInfo`: InstanceAPIClusterInfoOutput + fmt.Fprintf(os.Stdout, "Response from `ClusterApi.ClusterGetClusterInfo`: %v\n", resp) +} +``` + +### Path Parameters + +This endpoint does not need any parameter. + +### Other Parameters + +Other parameters are passed through a pointer to a apiClusterGetClusterInfoRequest struct via the builder pattern + + +### Return type + +[**InstanceAPIClusterInfoOutput**](InstanceAPIClusterInfoOutput.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + diff --git a/api/docs/ClusterInstancesApi.md b/api/docs/ClusterInstancesApi.md index 87970296d..5a9fa8cdf 100644 --- a/api/docs/ClusterInstancesApi.md +++ b/api/docs/ClusterInstancesApi.md @@ -4,15 +4,14 @@ All URIs are relative to *http://localhost* Method | HTTP request | Description ------------- | ------------- | ------------- -[**ClusterGetInfo**](ClusterInstancesApi.md#ClusterGetInfo) | **Get** /api/v1/cluster/info | Instance -[**ClusterGetInstances**](ClusterInstancesApi.md#ClusterGetInstances) | **Get** /api/v1/cluster/instances | Instances +[**ClusterGetInstanceInfo**](ClusterInstancesApi.md#ClusterGetInstanceInfo) | **Get** /api/v1/cluster/instance | Instance [**ClusterInstanceRoleRestart**](ClusterInstancesApi.md#ClusterInstanceRoleRestart) | **Post** /api/v1/cluster/roles/restart | Instance roles -## ClusterGetInfo +## ClusterGetInstanceInfo -> InstanceAPIInstanceInfo ClusterGetInfo(ctx).Execute() +> InstanceAPIInstanceInfo ClusterGetInstanceInfo(ctx).Execute() Instance @@ -32,13 +31,13 @@ func main() { configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) - resp, r, err := apiClient.ClusterInstancesApi.ClusterGetInfo(context.Background()).Execute() + resp, r, err := apiClient.ClusterInstancesApi.ClusterGetInstanceInfo(context.Background()).Execute() if err != nil { - fmt.Fprintf(os.Stderr, "Error when calling `ClusterInstancesApi.ClusterGetInfo``: %v\n", err) + fmt.Fprintf(os.Stderr, "Error when calling `ClusterInstancesApi.ClusterGetInstanceInfo``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } - // response from `ClusterGetInfo`: InstanceAPIInstanceInfo - fmt.Fprintf(os.Stdout, "Response from `ClusterInstancesApi.ClusterGetInfo`: %v\n", resp) + // response from `ClusterGetInstanceInfo`: InstanceAPIInstanceInfo + fmt.Fprintf(os.Stdout, "Response from `ClusterInstancesApi.ClusterGetInstanceInfo`: %v\n", resp) } ``` @@ -48,7 +47,7 @@ This endpoint does not need any parameter. ### Other Parameters -Other parameters are passed through a pointer to a apiClusterGetInfoRequest struct via the builder pattern +Other parameters are passed through a pointer to a apiClusterGetInstanceInfoRequest struct via the builder pattern ### Return type @@ -69,65 +68,6 @@ No authorization required [[Back to README]](../README.md) -## ClusterGetInstances - -> InstanceAPIInstancesOutput ClusterGetInstances(ctx).Execute() - -Instances - -### Example - -```go -package main - -import ( - "context" - "fmt" - "os" - openapiclient "beryju.io/gravity/api" -) - -func main() { - - configuration := openapiclient.NewConfiguration() - apiClient := openapiclient.NewAPIClient(configuration) - resp, r, err := apiClient.ClusterInstancesApi.ClusterGetInstances(context.Background()).Execute() - if err != nil { - fmt.Fprintf(os.Stderr, "Error when calling `ClusterInstancesApi.ClusterGetInstances``: %v\n", err) - fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) - } - // response from `ClusterGetInstances`: InstanceAPIInstancesOutput - fmt.Fprintf(os.Stdout, "Response from `ClusterInstancesApi.ClusterGetInstances`: %v\n", resp) -} -``` - -### Path Parameters - -This endpoint does not need any parameter. - -### Other Parameters - -Other parameters are passed through a pointer to a apiClusterGetInstancesRequest struct via the builder pattern - - -### Return type - -[**InstanceAPIInstancesOutput**](InstanceAPIInstancesOutput.md) - -### Authorization - -No authorization required - -### HTTP request headers - -- **Content-Type**: Not defined -- **Accept**: application/json - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) -[[Back to Model list]](../README.md#documentation-for-models) -[[Back to README]](../README.md) - - ## ClusterInstanceRoleRestart > ClusterInstanceRoleRestart(ctx).InstanceAPIRoleRestartInput(instanceAPIRoleRestartInput).Execute() diff --git a/api/docs/InstanceAPIClusterInfoOutput.md b/api/docs/InstanceAPIClusterInfoOutput.md new file mode 100644 index 000000000..43d8a53f2 --- /dev/null +++ b/api/docs/InstanceAPIClusterInfoOutput.md @@ -0,0 +1,103 @@ +# InstanceAPIClusterInfoOutput + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClusterVersion** | **string** | | +**ClusterVersionShort** | **string** | | +**Instances** | [**[]InstanceInstanceInfo**](InstanceInstanceInfo.md) | | + +## Methods + +### NewInstanceAPIClusterInfoOutput + +`func NewInstanceAPIClusterInfoOutput(clusterVersion string, clusterVersionShort string, instances []InstanceInstanceInfo, ) *InstanceAPIClusterInfoOutput` + +NewInstanceAPIClusterInfoOutput instantiates a new InstanceAPIClusterInfoOutput 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 + +### NewInstanceAPIClusterInfoOutputWithDefaults + +`func NewInstanceAPIClusterInfoOutputWithDefaults() *InstanceAPIClusterInfoOutput` + +NewInstanceAPIClusterInfoOutputWithDefaults instantiates a new InstanceAPIClusterInfoOutput 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 + +### GetClusterVersion + +`func (o *InstanceAPIClusterInfoOutput) GetClusterVersion() string` + +GetClusterVersion returns the ClusterVersion field if non-nil, zero value otherwise. + +### GetClusterVersionOk + +`func (o *InstanceAPIClusterInfoOutput) GetClusterVersionOk() (*string, bool)` + +GetClusterVersionOk returns a tuple with the ClusterVersion field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetClusterVersion + +`func (o *InstanceAPIClusterInfoOutput) SetClusterVersion(v string)` + +SetClusterVersion sets ClusterVersion field to given value. + + +### GetClusterVersionShort + +`func (o *InstanceAPIClusterInfoOutput) GetClusterVersionShort() string` + +GetClusterVersionShort returns the ClusterVersionShort field if non-nil, zero value otherwise. + +### GetClusterVersionShortOk + +`func (o *InstanceAPIClusterInfoOutput) GetClusterVersionShortOk() (*string, bool)` + +GetClusterVersionShortOk returns a tuple with the ClusterVersionShort field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetClusterVersionShort + +`func (o *InstanceAPIClusterInfoOutput) SetClusterVersionShort(v string)` + +SetClusterVersionShort sets ClusterVersionShort field to given value. + + +### GetInstances + +`func (o *InstanceAPIClusterInfoOutput) GetInstances() []InstanceInstanceInfo` + +GetInstances returns the Instances field if non-nil, zero value otherwise. + +### GetInstancesOk + +`func (o *InstanceAPIClusterInfoOutput) GetInstancesOk() (*[]InstanceInstanceInfo, bool)` + +GetInstancesOk returns a tuple with the Instances field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetInstances + +`func (o *InstanceAPIClusterInfoOutput) SetInstances(v []InstanceInstanceInfo)` + +SetInstances sets Instances field to given value. + + +### SetInstancesNil + +`func (o *InstanceAPIClusterInfoOutput) SetInstancesNil(b bool)` + + SetInstancesNil sets the value for Instances to be an explicit nil + +### UnsetInstances +`func (o *InstanceAPIClusterInfoOutput) UnsetInstances()` + +UnsetInstances ensures that no value is present for Instances, not even an explicit nil + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api/docs/InstanceAPIInstanceInfo.md b/api/docs/InstanceAPIInstanceInfo.md index 67b8995de..fab460379 100644 --- a/api/docs/InstanceAPIInstanceInfo.md +++ b/api/docs/InstanceAPIInstanceInfo.md @@ -5,16 +5,16 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **BuildHash** | **string** | | -**CurrentInstanceIP** | **string** | | -**CurrentInstanceIdentifier** | **string** | | **Dirs** | [**ExtconfigExtConfigDirs**](ExtconfigExtConfigDirs.md) | | +**InstanceIP** | **string** | | +**InstanceIdentifier** | **string** | | **Version** | **string** | | ## Methods ### NewInstanceAPIInstanceInfo -`func NewInstanceAPIInstanceInfo(buildHash string, currentInstanceIP string, currentInstanceIdentifier string, dirs ExtconfigExtConfigDirs, version string, ) *InstanceAPIInstanceInfo` +`func NewInstanceAPIInstanceInfo(buildHash string, dirs ExtconfigExtConfigDirs, instanceIP string, instanceIdentifier string, version string, ) *InstanceAPIInstanceInfo` NewInstanceAPIInstanceInfo instantiates a new InstanceAPIInstanceInfo object This constructor will assign default values to properties that have it defined, @@ -49,64 +49,64 @@ and a boolean to check if the value has been set. SetBuildHash sets BuildHash field to given value. -### GetCurrentInstanceIP +### GetDirs -`func (o *InstanceAPIInstanceInfo) GetCurrentInstanceIP() string` +`func (o *InstanceAPIInstanceInfo) GetDirs() ExtconfigExtConfigDirs` -GetCurrentInstanceIP returns the CurrentInstanceIP field if non-nil, zero value otherwise. +GetDirs returns the Dirs field if non-nil, zero value otherwise. -### GetCurrentInstanceIPOk +### GetDirsOk -`func (o *InstanceAPIInstanceInfo) GetCurrentInstanceIPOk() (*string, bool)` +`func (o *InstanceAPIInstanceInfo) GetDirsOk() (*ExtconfigExtConfigDirs, bool)` -GetCurrentInstanceIPOk returns a tuple with the CurrentInstanceIP field if it's non-nil, zero value otherwise +GetDirsOk returns a tuple with the Dirs field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetCurrentInstanceIP +### SetDirs -`func (o *InstanceAPIInstanceInfo) SetCurrentInstanceIP(v string)` +`func (o *InstanceAPIInstanceInfo) SetDirs(v ExtconfigExtConfigDirs)` -SetCurrentInstanceIP sets CurrentInstanceIP field to given value. +SetDirs sets Dirs field to given value. -### GetCurrentInstanceIdentifier +### GetInstanceIP -`func (o *InstanceAPIInstanceInfo) GetCurrentInstanceIdentifier() string` +`func (o *InstanceAPIInstanceInfo) GetInstanceIP() string` -GetCurrentInstanceIdentifier returns the CurrentInstanceIdentifier field if non-nil, zero value otherwise. +GetInstanceIP returns the InstanceIP field if non-nil, zero value otherwise. -### GetCurrentInstanceIdentifierOk +### GetInstanceIPOk -`func (o *InstanceAPIInstanceInfo) GetCurrentInstanceIdentifierOk() (*string, bool)` +`func (o *InstanceAPIInstanceInfo) GetInstanceIPOk() (*string, bool)` -GetCurrentInstanceIdentifierOk returns a tuple with the CurrentInstanceIdentifier field if it's non-nil, zero value otherwise +GetInstanceIPOk returns a tuple with the InstanceIP field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetCurrentInstanceIdentifier +### SetInstanceIP -`func (o *InstanceAPIInstanceInfo) SetCurrentInstanceIdentifier(v string)` +`func (o *InstanceAPIInstanceInfo) SetInstanceIP(v string)` -SetCurrentInstanceIdentifier sets CurrentInstanceIdentifier field to given value. +SetInstanceIP sets InstanceIP field to given value. -### GetDirs +### GetInstanceIdentifier -`func (o *InstanceAPIInstanceInfo) GetDirs() ExtconfigExtConfigDirs` +`func (o *InstanceAPIInstanceInfo) GetInstanceIdentifier() string` -GetDirs returns the Dirs field if non-nil, zero value otherwise. +GetInstanceIdentifier returns the InstanceIdentifier field if non-nil, zero value otherwise. -### GetDirsOk +### GetInstanceIdentifierOk -`func (o *InstanceAPIInstanceInfo) GetDirsOk() (*ExtconfigExtConfigDirs, bool)` +`func (o *InstanceAPIInstanceInfo) GetInstanceIdentifierOk() (*string, bool)` -GetDirsOk returns a tuple with the Dirs field if it's non-nil, zero value otherwise +GetInstanceIdentifierOk returns a tuple with the InstanceIdentifier field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetDirs +### SetInstanceIdentifier -`func (o *InstanceAPIInstanceInfo) SetDirs(v ExtconfigExtConfigDirs)` +`func (o *InstanceAPIInstanceInfo) SetInstanceIdentifier(v string)` -SetDirs sets Dirs field to given value. +SetInstanceIdentifier sets InstanceIdentifier field to given value. ### GetVersion diff --git a/api/model_instance_api_cluster_info_output.go b/api/model_instance_api_cluster_info_output.go new file mode 100644 index 000000000..1d8b5f5d4 --- /dev/null +++ b/api/model_instance_api_cluster_info_output.go @@ -0,0 +1,173 @@ +/* +gravity + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +API version: 0.16.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package api + +import ( + "encoding/json" +) + +// checks if the InstanceAPIClusterInfoOutput type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &InstanceAPIClusterInfoOutput{} + +// InstanceAPIClusterInfoOutput struct for InstanceAPIClusterInfoOutput +type InstanceAPIClusterInfoOutput struct { + ClusterVersion string `json:"clusterVersion"` + ClusterVersionShort string `json:"clusterVersionShort"` + Instances []InstanceInstanceInfo `json:"instances"` +} + +// NewInstanceAPIClusterInfoOutput instantiates a new InstanceAPIClusterInfoOutput 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 NewInstanceAPIClusterInfoOutput(clusterVersion string, clusterVersionShort string, instances []InstanceInstanceInfo) *InstanceAPIClusterInfoOutput { + this := InstanceAPIClusterInfoOutput{} + this.ClusterVersion = clusterVersion + this.ClusterVersionShort = clusterVersionShort + this.Instances = instances + return &this +} + +// NewInstanceAPIClusterInfoOutputWithDefaults instantiates a new InstanceAPIClusterInfoOutput 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 NewInstanceAPIClusterInfoOutputWithDefaults() *InstanceAPIClusterInfoOutput { + this := InstanceAPIClusterInfoOutput{} + return &this +} + +// GetClusterVersion returns the ClusterVersion field value +func (o *InstanceAPIClusterInfoOutput) GetClusterVersion() string { + if o == nil { + var ret string + return ret + } + + return o.ClusterVersion +} + +// GetClusterVersionOk returns a tuple with the ClusterVersion field value +// and a boolean to check if the value has been set. +func (o *InstanceAPIClusterInfoOutput) GetClusterVersionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ClusterVersion, true +} + +// SetClusterVersion sets field value +func (o *InstanceAPIClusterInfoOutput) SetClusterVersion(v string) { + o.ClusterVersion = v +} + +// GetClusterVersionShort returns the ClusterVersionShort field value +func (o *InstanceAPIClusterInfoOutput) GetClusterVersionShort() string { + if o == nil { + var ret string + return ret + } + + return o.ClusterVersionShort +} + +// GetClusterVersionShortOk returns a tuple with the ClusterVersionShort field value +// and a boolean to check if the value has been set. +func (o *InstanceAPIClusterInfoOutput) GetClusterVersionShortOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ClusterVersionShort, true +} + +// SetClusterVersionShort sets field value +func (o *InstanceAPIClusterInfoOutput) SetClusterVersionShort(v string) { + o.ClusterVersionShort = v +} + +// GetInstances returns the Instances field value +// If the value is explicit nil, the zero value for []InstanceInstanceInfo will be returned +func (o *InstanceAPIClusterInfoOutput) GetInstances() []InstanceInstanceInfo { + if o == nil { + var ret []InstanceInstanceInfo + return ret + } + + return o.Instances +} + +// GetInstancesOk returns a tuple with the Instances field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *InstanceAPIClusterInfoOutput) GetInstancesOk() ([]InstanceInstanceInfo, bool) { + if o == nil || IsNil(o.Instances) { + return nil, false + } + return o.Instances, true +} + +// SetInstances sets field value +func (o *InstanceAPIClusterInfoOutput) SetInstances(v []InstanceInstanceInfo) { + o.Instances = v +} + +func (o InstanceAPIClusterInfoOutput) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o InstanceAPIClusterInfoOutput) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["clusterVersion"] = o.ClusterVersion + toSerialize["clusterVersionShort"] = o.ClusterVersionShort + if o.Instances != nil { + toSerialize["instances"] = o.Instances + } + return toSerialize, nil +} + +type NullableInstanceAPIClusterInfoOutput struct { + value *InstanceAPIClusterInfoOutput + isSet bool +} + +func (v NullableInstanceAPIClusterInfoOutput) Get() *InstanceAPIClusterInfoOutput { + return v.value +} + +func (v *NullableInstanceAPIClusterInfoOutput) Set(val *InstanceAPIClusterInfoOutput) { + v.value = val + v.isSet = true +} + +func (v NullableInstanceAPIClusterInfoOutput) IsSet() bool { + return v.isSet +} + +func (v *NullableInstanceAPIClusterInfoOutput) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInstanceAPIClusterInfoOutput(val *InstanceAPIClusterInfoOutput) *NullableInstanceAPIClusterInfoOutput { + return &NullableInstanceAPIClusterInfoOutput{value: val, isSet: true} +} + +func (v NullableInstanceAPIClusterInfoOutput) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInstanceAPIClusterInfoOutput) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/model_instance_api_instance_info.go b/api/model_instance_api_instance_info.go index 11964323e..212bc8b6c 100644 --- a/api/model_instance_api_instance_info.go +++ b/api/model_instance_api_instance_info.go @@ -19,23 +19,23 @@ var _ MappedNullable = &InstanceAPIInstanceInfo{} // InstanceAPIInstanceInfo struct for InstanceAPIInstanceInfo type InstanceAPIInstanceInfo struct { - BuildHash string `json:"buildHash"` - CurrentInstanceIP string `json:"currentInstanceIP"` - CurrentInstanceIdentifier string `json:"currentInstanceIdentifier"` - Dirs ExtconfigExtConfigDirs `json:"dirs"` - Version string `json:"version"` + BuildHash string `json:"buildHash"` + Dirs ExtconfigExtConfigDirs `json:"dirs"` + InstanceIP string `json:"instanceIP"` + InstanceIdentifier string `json:"instanceIdentifier"` + Version string `json:"version"` } // NewInstanceAPIInstanceInfo instantiates a new InstanceAPIInstanceInfo 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 NewInstanceAPIInstanceInfo(buildHash string, currentInstanceIP string, currentInstanceIdentifier string, dirs ExtconfigExtConfigDirs, version string) *InstanceAPIInstanceInfo { +func NewInstanceAPIInstanceInfo(buildHash string, dirs ExtconfigExtConfigDirs, instanceIP string, instanceIdentifier string, version string) *InstanceAPIInstanceInfo { this := InstanceAPIInstanceInfo{} this.BuildHash = buildHash - this.CurrentInstanceIP = currentInstanceIP - this.CurrentInstanceIdentifier = currentInstanceIdentifier this.Dirs = dirs + this.InstanceIP = instanceIP + this.InstanceIdentifier = instanceIdentifier this.Version = version return &this } @@ -72,76 +72,76 @@ func (o *InstanceAPIInstanceInfo) SetBuildHash(v string) { o.BuildHash = v } -// GetCurrentInstanceIP returns the CurrentInstanceIP field value -func (o *InstanceAPIInstanceInfo) GetCurrentInstanceIP() string { +// GetDirs returns the Dirs field value +func (o *InstanceAPIInstanceInfo) GetDirs() ExtconfigExtConfigDirs { if o == nil { - var ret string + var ret ExtconfigExtConfigDirs return ret } - return o.CurrentInstanceIP + return o.Dirs } -// GetCurrentInstanceIPOk returns a tuple with the CurrentInstanceIP field value +// GetDirsOk returns a tuple with the Dirs field value // and a boolean to check if the value has been set. -func (o *InstanceAPIInstanceInfo) GetCurrentInstanceIPOk() (*string, bool) { +func (o *InstanceAPIInstanceInfo) GetDirsOk() (*ExtconfigExtConfigDirs, bool) { if o == nil { return nil, false } - return &o.CurrentInstanceIP, true + return &o.Dirs, true } -// SetCurrentInstanceIP sets field value -func (o *InstanceAPIInstanceInfo) SetCurrentInstanceIP(v string) { - o.CurrentInstanceIP = v +// SetDirs sets field value +func (o *InstanceAPIInstanceInfo) SetDirs(v ExtconfigExtConfigDirs) { + o.Dirs = v } -// GetCurrentInstanceIdentifier returns the CurrentInstanceIdentifier field value -func (o *InstanceAPIInstanceInfo) GetCurrentInstanceIdentifier() string { +// GetInstanceIP returns the InstanceIP field value +func (o *InstanceAPIInstanceInfo) GetInstanceIP() string { if o == nil { var ret string return ret } - return o.CurrentInstanceIdentifier + return o.InstanceIP } -// GetCurrentInstanceIdentifierOk returns a tuple with the CurrentInstanceIdentifier field value +// GetInstanceIPOk returns a tuple with the InstanceIP field value // and a boolean to check if the value has been set. -func (o *InstanceAPIInstanceInfo) GetCurrentInstanceIdentifierOk() (*string, bool) { +func (o *InstanceAPIInstanceInfo) GetInstanceIPOk() (*string, bool) { if o == nil { return nil, false } - return &o.CurrentInstanceIdentifier, true + return &o.InstanceIP, true } -// SetCurrentInstanceIdentifier sets field value -func (o *InstanceAPIInstanceInfo) SetCurrentInstanceIdentifier(v string) { - o.CurrentInstanceIdentifier = v +// SetInstanceIP sets field value +func (o *InstanceAPIInstanceInfo) SetInstanceIP(v string) { + o.InstanceIP = v } -// GetDirs returns the Dirs field value -func (o *InstanceAPIInstanceInfo) GetDirs() ExtconfigExtConfigDirs { +// GetInstanceIdentifier returns the InstanceIdentifier field value +func (o *InstanceAPIInstanceInfo) GetInstanceIdentifier() string { if o == nil { - var ret ExtconfigExtConfigDirs + var ret string return ret } - return o.Dirs + return o.InstanceIdentifier } -// GetDirsOk returns a tuple with the Dirs field value +// GetInstanceIdentifierOk returns a tuple with the InstanceIdentifier field value // and a boolean to check if the value has been set. -func (o *InstanceAPIInstanceInfo) GetDirsOk() (*ExtconfigExtConfigDirs, bool) { +func (o *InstanceAPIInstanceInfo) GetInstanceIdentifierOk() (*string, bool) { if o == nil { return nil, false } - return &o.Dirs, true + return &o.InstanceIdentifier, true } -// SetDirs sets field value -func (o *InstanceAPIInstanceInfo) SetDirs(v ExtconfigExtConfigDirs) { - o.Dirs = v +// SetInstanceIdentifier sets field value +func (o *InstanceAPIInstanceInfo) SetInstanceIdentifier(v string) { + o.InstanceIdentifier = v } // GetVersion returns the Version field value @@ -179,9 +179,9 @@ func (o InstanceAPIInstanceInfo) MarshalJSON() ([]byte, error) { func (o InstanceAPIInstanceInfo) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} toSerialize["buildHash"] = o.BuildHash - toSerialize["currentInstanceIP"] = o.CurrentInstanceIP - toSerialize["currentInstanceIdentifier"] = o.CurrentInstanceIdentifier toSerialize["dirs"] = o.Dirs + toSerialize["instanceIP"] = o.InstanceIP + toSerialize["instanceIdentifier"] = o.InstanceIdentifier toSerialize["version"] = o.Version return toSerialize, nil } diff --git a/api/test/api_cluster_test.go b/api/test/api_cluster_test.go new file mode 100644 index 000000000..7b1d21ed9 --- /dev/null +++ b/api/test/api_cluster_test.go @@ -0,0 +1,35 @@ +/* +gravity + +Testing ClusterApiService + +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); + +package api + +import ( + "context" + "testing" + + openapiclient "beryju.io/gravity/api" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func Test_api_ClusterApiService(t *testing.T) { + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + + t.Run("Test ClusterApiService ClusterGetClusterInfo", func(t *testing.T) { + t.Skip("skip test") // remove to run test + + resp, httpRes, err := apiClient.ClusterApi.ClusterGetClusterInfo(context.Background()).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + }) +} diff --git a/cmd/cli/cli_health.go b/cmd/cli/cli_health.go index 12595e6b5..7a719b10d 100644 --- a/cmd/cli/cli_health.go +++ b/cmd/cli/cli_health.go @@ -10,7 +10,7 @@ var healthCmd = &cobra.Command{ Use: "health", Short: "Check health and version", Run: func(cmd *cobra.Command, args []string) { - v, hr, err := apiClient.ClusterInstancesApi.ClusterGetInfo(cmd.Context()).Execute() + v, hr, err := apiClient.ClusterInstancesApi.ClusterGetInstanceInfo(cmd.Context()).Execute() if err != nil { checkApiError(hr, err) os.Exit(1)