From 2cc181bdfd31918fe8ac81319f22fe3119e5126a Mon Sep 17 00:00:00 2001 From: Daniel Baptista Dias Date: Thu, 27 Apr 2023 14:51:49 -0300 Subject: [PATCH] Updating mappings for DataStores (#2454) * Updating mappings * Updating OpenAPI based structs * Update FE --------- Co-authored-by: Jorge Padilla --- api/dataStores.yaml | 8 +- cli/formatters/datastore_list.go | 2 +- cli/openapi/api_resource_api.go | 8 +- cli/openapi/model_data_store.go | 136 +++++++-------- cli/openapi/model_data_store_resource.go | 161 ++++++++++++++++++ cli/openapi/model_supported_data_stores.go | 28 +-- server/http/mappings/datastore.go | 14 +- server/openapi/api_resource_api_service.go | 4 +- server/openapi/model_data_store.go | 12 +- server/openapi/model_data_store_resource.go | 39 +++++ server/openapi/model_supported_data_stores.go | 20 +-- .../datastoreresource/repository_test.go | 12 +- .../datastoreresource/resource_types.go | 6 +- web/src/models/DataStore.model.ts | 14 +- .../services/DataStores/SignalFx.service.ts | 12 +- web/src/types/DataStore.types.ts | 14 +- web/src/types/Generated.types.ts | 26 ++- 17 files changed, 364 insertions(+), 152 deletions(-) create mode 100644 cli/openapi/model_data_store_resource.go create mode 100644 server/openapi/model_data_store_resource.go diff --git a/api/dataStores.yaml b/api/dataStores.yaml index 59a032c270..59700c920f 100644 --- a/api/dataStores.yaml +++ b/api/dataStores.yaml @@ -31,11 +31,11 @@ components: $ref: "#/components/schemas/GRPCClientSettings" tempo: $ref: "#/components/schemas/BaseClient" - openSearch: + opensearch: $ref: "#/components/schemas/ElasticSearch" - elasticApm: + elasticapm: $ref: "#/components/schemas/ElasticSearch" - signalFx: + signalfx: $ref: "#/components/schemas/SignalFX" awsxray: $ref: "#/components/schemas/AwsXRay" @@ -158,7 +158,7 @@ components: type: string SupportedDataStores: type: string - enum: [jaeger, openSearch, tempo, signalFx, otlp, elasticApm, newRelic, lightstep, datadog, awsxray] + enum: [jaeger, opensearch, tempo, signalfx, otlp, elasticapm, newrelic, lightstep, datadog, awsxray] SupportedClients: type: string enum: [http, grpc] diff --git a/cli/formatters/datastore_list.go b/cli/formatters/datastore_list.go index 918e73115b..238320d025 100644 --- a/cli/formatters/datastore_list.go +++ b/cli/formatters/datastore_list.go @@ -68,7 +68,7 @@ func (f dataStoreList) pretty(dataStores []openapi.DataStore) string { } func (f dataStoreList) getDefaultMark(dataStore openapi.DataStore) string { - if dataStore.IsDefault != nil && *dataStore.IsDefault { + if dataStore.Default != nil && *dataStore.Default { return "*" } diff --git a/cli/openapi/api_resource_api.go b/cli/openapi/api_resource_api.go index 9cfab1b44a..9a803473f0 100644 --- a/cli/openapi/api_resource_api.go +++ b/cli/openapi/api_resource_api.go @@ -424,7 +424,7 @@ type ApiGetDataStoreRequest struct { dataStoreId string } -func (r ApiGetDataStoreRequest) Execute() (*DataStore, *http.Response, error) { +func (r ApiGetDataStoreRequest) Execute() (*DataStoreResource, *http.Response, error) { return r.ApiService.GetDataStoreExecute(r) } @@ -447,13 +447,13 @@ func (a *ResourceApiApiService) GetDataStore(ctx context.Context, dataStoreId st // Execute executes the request // -// @return DataStore -func (a *ResourceApiApiService) GetDataStoreExecute(r ApiGetDataStoreRequest) (*DataStore, *http.Response, error) { +// @return DataStoreResource +func (a *ResourceApiApiService) GetDataStoreExecute(r ApiGetDataStoreRequest) (*DataStoreResource, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue *DataStore + localVarReturnValue *DataStoreResource ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ResourceApiApiService.GetDataStore") diff --git a/cli/openapi/model_data_store.go b/cli/openapi/model_data_store.go index a5afe70f1b..5b2281c26a 100644 --- a/cli/openapi/model_data_store.go +++ b/cli/openapi/model_data_store.go @@ -23,12 +23,12 @@ type DataStore struct { Id *string `json:"id,omitempty"` Name string `json:"name"` Type SupportedDataStores `json:"type"` - IsDefault *bool `json:"isDefault,omitempty"` + Default *bool `json:"default,omitempty"` Jaeger *GRPCClientSettings `json:"jaeger,omitempty"` Tempo *BaseClient `json:"tempo,omitempty"` - OpenSearch *ElasticSearch `json:"openSearch,omitempty"` - ElasticApm *ElasticSearch `json:"elasticApm,omitempty"` - SignalFx *SignalFX `json:"signalFx,omitempty"` + Opensearch *ElasticSearch `json:"opensearch,omitempty"` + Elasticapm *ElasticSearch `json:"elasticapm,omitempty"` + Signalfx *SignalFX `json:"signalfx,omitempty"` Awsxray *AwsXRay `json:"awsxray,omitempty"` CreatedAt *time.Time `json:"createdAt,omitempty"` } @@ -132,36 +132,36 @@ func (o *DataStore) SetType(v SupportedDataStores) { o.Type = v } -// GetIsDefault returns the IsDefault field value if set, zero value otherwise. -func (o *DataStore) GetIsDefault() bool { - if o == nil || isNil(o.IsDefault) { +// GetDefault returns the Default field value if set, zero value otherwise. +func (o *DataStore) GetDefault() bool { + if o == nil || isNil(o.Default) { var ret bool return ret } - return *o.IsDefault + return *o.Default } -// GetIsDefaultOk returns a tuple with the IsDefault field value if set, nil otherwise +// GetDefaultOk returns a tuple with the Default field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *DataStore) GetIsDefaultOk() (*bool, bool) { - if o == nil || isNil(o.IsDefault) { +func (o *DataStore) GetDefaultOk() (*bool, bool) { + if o == nil || isNil(o.Default) { return nil, false } - return o.IsDefault, true + return o.Default, true } -// HasIsDefault returns a boolean if a field has been set. -func (o *DataStore) HasIsDefault() bool { - if o != nil && !isNil(o.IsDefault) { +// HasDefault returns a boolean if a field has been set. +func (o *DataStore) HasDefault() bool { + if o != nil && !isNil(o.Default) { return true } return false } -// SetIsDefault gets a reference to the given bool and assigns it to the IsDefault field. -func (o *DataStore) SetIsDefault(v bool) { - o.IsDefault = &v +// SetDefault gets a reference to the given bool and assigns it to the Default field. +func (o *DataStore) SetDefault(v bool) { + o.Default = &v } // GetJaeger returns the Jaeger field value if set, zero value otherwise. @@ -228,100 +228,100 @@ func (o *DataStore) SetTempo(v BaseClient) { o.Tempo = &v } -// GetOpenSearch returns the OpenSearch field value if set, zero value otherwise. -func (o *DataStore) GetOpenSearch() ElasticSearch { - if o == nil || isNil(o.OpenSearch) { +// GetOpensearch returns the Opensearch field value if set, zero value otherwise. +func (o *DataStore) GetOpensearch() ElasticSearch { + if o == nil || isNil(o.Opensearch) { var ret ElasticSearch return ret } - return *o.OpenSearch + return *o.Opensearch } -// GetOpenSearchOk returns a tuple with the OpenSearch field value if set, nil otherwise +// GetOpensearchOk returns a tuple with the Opensearch field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *DataStore) GetOpenSearchOk() (*ElasticSearch, bool) { - if o == nil || isNil(o.OpenSearch) { +func (o *DataStore) GetOpensearchOk() (*ElasticSearch, bool) { + if o == nil || isNil(o.Opensearch) { return nil, false } - return o.OpenSearch, true + return o.Opensearch, true } -// HasOpenSearch returns a boolean if a field has been set. -func (o *DataStore) HasOpenSearch() bool { - if o != nil && !isNil(o.OpenSearch) { +// HasOpensearch returns a boolean if a field has been set. +func (o *DataStore) HasOpensearch() bool { + if o != nil && !isNil(o.Opensearch) { return true } return false } -// SetOpenSearch gets a reference to the given ElasticSearch and assigns it to the OpenSearch field. -func (o *DataStore) SetOpenSearch(v ElasticSearch) { - o.OpenSearch = &v +// SetOpensearch gets a reference to the given ElasticSearch and assigns it to the Opensearch field. +func (o *DataStore) SetOpensearch(v ElasticSearch) { + o.Opensearch = &v } -// GetElasticApm returns the ElasticApm field value if set, zero value otherwise. -func (o *DataStore) GetElasticApm() ElasticSearch { - if o == nil || isNil(o.ElasticApm) { +// GetElasticapm returns the Elasticapm field value if set, zero value otherwise. +func (o *DataStore) GetElasticapm() ElasticSearch { + if o == nil || isNil(o.Elasticapm) { var ret ElasticSearch return ret } - return *o.ElasticApm + return *o.Elasticapm } -// GetElasticApmOk returns a tuple with the ElasticApm field value if set, nil otherwise +// GetElasticapmOk returns a tuple with the Elasticapm field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *DataStore) GetElasticApmOk() (*ElasticSearch, bool) { - if o == nil || isNil(o.ElasticApm) { +func (o *DataStore) GetElasticapmOk() (*ElasticSearch, bool) { + if o == nil || isNil(o.Elasticapm) { return nil, false } - return o.ElasticApm, true + return o.Elasticapm, true } -// HasElasticApm returns a boolean if a field has been set. -func (o *DataStore) HasElasticApm() bool { - if o != nil && !isNil(o.ElasticApm) { +// HasElasticapm returns a boolean if a field has been set. +func (o *DataStore) HasElasticapm() bool { + if o != nil && !isNil(o.Elasticapm) { return true } return false } -// SetElasticApm gets a reference to the given ElasticSearch and assigns it to the ElasticApm field. -func (o *DataStore) SetElasticApm(v ElasticSearch) { - o.ElasticApm = &v +// SetElasticapm gets a reference to the given ElasticSearch and assigns it to the Elasticapm field. +func (o *DataStore) SetElasticapm(v ElasticSearch) { + o.Elasticapm = &v } -// GetSignalFx returns the SignalFx field value if set, zero value otherwise. -func (o *DataStore) GetSignalFx() SignalFX { - if o == nil || isNil(o.SignalFx) { +// GetSignalfx returns the Signalfx field value if set, zero value otherwise. +func (o *DataStore) GetSignalfx() SignalFX { + if o == nil || isNil(o.Signalfx) { var ret SignalFX return ret } - return *o.SignalFx + return *o.Signalfx } -// GetSignalFxOk returns a tuple with the SignalFx field value if set, nil otherwise +// GetSignalfxOk returns a tuple with the Signalfx field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *DataStore) GetSignalFxOk() (*SignalFX, bool) { - if o == nil || isNil(o.SignalFx) { +func (o *DataStore) GetSignalfxOk() (*SignalFX, bool) { + if o == nil || isNil(o.Signalfx) { return nil, false } - return o.SignalFx, true + return o.Signalfx, true } -// HasSignalFx returns a boolean if a field has been set. -func (o *DataStore) HasSignalFx() bool { - if o != nil && !isNil(o.SignalFx) { +// HasSignalfx returns a boolean if a field has been set. +func (o *DataStore) HasSignalfx() bool { + if o != nil && !isNil(o.Signalfx) { return true } return false } -// SetSignalFx gets a reference to the given SignalFX and assigns it to the SignalFx field. -func (o *DataStore) SetSignalFx(v SignalFX) { - o.SignalFx = &v +// SetSignalfx gets a reference to the given SignalFX and assigns it to the Signalfx field. +func (o *DataStore) SetSignalfx(v SignalFX) { + o.Signalfx = &v } // GetAwsxray returns the Awsxray field value if set, zero value otherwise. @@ -401,8 +401,8 @@ func (o DataStore) ToMap() (map[string]interface{}, error) { // skip: id is readOnly toSerialize["name"] = o.Name toSerialize["type"] = o.Type - if !isNil(o.IsDefault) { - toSerialize["isDefault"] = o.IsDefault + if !isNil(o.Default) { + toSerialize["default"] = o.Default } if !isNil(o.Jaeger) { toSerialize["jaeger"] = o.Jaeger @@ -410,14 +410,14 @@ func (o DataStore) ToMap() (map[string]interface{}, error) { if !isNil(o.Tempo) { toSerialize["tempo"] = o.Tempo } - if !isNil(o.OpenSearch) { - toSerialize["openSearch"] = o.OpenSearch + if !isNil(o.Opensearch) { + toSerialize["opensearch"] = o.Opensearch } - if !isNil(o.ElasticApm) { - toSerialize["elasticApm"] = o.ElasticApm + if !isNil(o.Elasticapm) { + toSerialize["elasticapm"] = o.Elasticapm } - if !isNil(o.SignalFx) { - toSerialize["signalFx"] = o.SignalFx + if !isNil(o.Signalfx) { + toSerialize["signalfx"] = o.Signalfx } if !isNil(o.Awsxray) { toSerialize["awsxray"] = o.Awsxray diff --git a/cli/openapi/model_data_store_resource.go b/cli/openapi/model_data_store_resource.go new file mode 100644 index 0000000000..4e217d57db --- /dev/null +++ b/cli/openapi/model_data_store_resource.go @@ -0,0 +1,161 @@ +/* +TraceTest + +OpenAPI definition for TraceTest endpoint and resources + +API version: 0.2.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package openapi + +import ( + "encoding/json" +) + +// checks if the DataStoreResource type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &DataStoreResource{} + +// DataStoreResource Represents a data store structured into the Resources format. +type DataStoreResource struct { + // Represents the type of this resource. It should always be set as 'DataStore'. + Type *string `json:"type,omitempty"` + Spec *DataStore `json:"spec,omitempty"` +} + +// NewDataStoreResource instantiates a new DataStoreResource 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 NewDataStoreResource() *DataStoreResource { + this := DataStoreResource{} + return &this +} + +// NewDataStoreResourceWithDefaults instantiates a new DataStoreResource 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 NewDataStoreResourceWithDefaults() *DataStoreResource { + this := DataStoreResource{} + return &this +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *DataStoreResource) GetType() string { + if o == nil || isNil(o.Type) { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DataStoreResource) GetTypeOk() (*string, bool) { + if o == nil || isNil(o.Type) { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *DataStoreResource) HasType() bool { + if o != nil && !isNil(o.Type) { + return true + } + + return false +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *DataStoreResource) SetType(v string) { + o.Type = &v +} + +// GetSpec returns the Spec field value if set, zero value otherwise. +func (o *DataStoreResource) GetSpec() DataStore { + if o == nil || isNil(o.Spec) { + var ret DataStore + return ret + } + return *o.Spec +} + +// GetSpecOk returns a tuple with the Spec field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DataStoreResource) GetSpecOk() (*DataStore, bool) { + if o == nil || isNil(o.Spec) { + return nil, false + } + return o.Spec, true +} + +// HasSpec returns a boolean if a field has been set. +func (o *DataStoreResource) HasSpec() bool { + if o != nil && !isNil(o.Spec) { + return true + } + + return false +} + +// SetSpec gets a reference to the given DataStore and assigns it to the Spec field. +func (o *DataStoreResource) SetSpec(v DataStore) { + o.Spec = &v +} + +func (o DataStoreResource) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o DataStoreResource) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !isNil(o.Type) { + toSerialize["type"] = o.Type + } + if !isNil(o.Spec) { + toSerialize["spec"] = o.Spec + } + return toSerialize, nil +} + +type NullableDataStoreResource struct { + value *DataStoreResource + isSet bool +} + +func (v NullableDataStoreResource) Get() *DataStoreResource { + return v.value +} + +func (v *NullableDataStoreResource) Set(val *DataStoreResource) { + v.value = val + v.isSet = true +} + +func (v NullableDataStoreResource) IsSet() bool { + return v.isSet +} + +func (v *NullableDataStoreResource) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableDataStoreResource(val *DataStoreResource) *NullableDataStoreResource { + return &NullableDataStoreResource{value: val, isSet: true} +} + +func (v NullableDataStoreResource) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableDataStoreResource) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/cli/openapi/model_supported_data_stores.go b/cli/openapi/model_supported_data_stores.go index 7ee29694b9..e62ae68018 100644 --- a/cli/openapi/model_supported_data_stores.go +++ b/cli/openapi/model_supported_data_stores.go @@ -20,27 +20,27 @@ type SupportedDataStores string // List of SupportedDataStores const ( - JAEGER SupportedDataStores = "jaeger" - OPEN_SEARCH SupportedDataStores = "openSearch" - TEMPO SupportedDataStores = "tempo" - SIGNAL_FX SupportedDataStores = "signalFx" - OTLP SupportedDataStores = "otlp" - ELASTIC_APM SupportedDataStores = "elasticApm" - NEW_RELIC SupportedDataStores = "newRelic" - LIGHTSTEP SupportedDataStores = "lightstep" - DATADOG SupportedDataStores = "datadog" - AWSXRAY SupportedDataStores = "awsxray" + JAEGER SupportedDataStores = "jaeger" + OPENSEARCH SupportedDataStores = "opensearch" + TEMPO SupportedDataStores = "tempo" + SIGNALFX SupportedDataStores = "signalfx" + OTLP SupportedDataStores = "otlp" + ELASTICAPM SupportedDataStores = "elasticapm" + NEWRELIC SupportedDataStores = "newrelic" + LIGHTSTEP SupportedDataStores = "lightstep" + DATADOG SupportedDataStores = "datadog" + AWSXRAY SupportedDataStores = "awsxray" ) // All allowed values of SupportedDataStores enum var AllowedSupportedDataStoresEnumValues = []SupportedDataStores{ "jaeger", - "openSearch", + "opensearch", "tempo", - "signalFx", + "signalfx", "otlp", - "elasticApm", - "newRelic", + "elasticapm", + "newrelic", "lightstep", "datadog", "awsxray", diff --git a/server/http/mappings/datastore.go b/server/http/mappings/datastore.go index e162d859e9..b8e8c1b9b2 100644 --- a/server/http/mappings/datastore.go +++ b/server/http/mappings/datastore.go @@ -49,12 +49,12 @@ func (m *OpenAPI) ConnectionTestStep(in model.ConnectionTestStep) openapi.Connec var dataStoreTypesMapping = map[datastoreresource.DataStoreType]openapi.SupportedDataStores{ datastoreresource.DataStoreTypeJaeger: openapi.JAEGER, datastoreresource.DataStoreTypeTempo: openapi.TEMPO, - datastoreresource.DataStoreTypeOpenSearch: openapi.OPEN_SEARCH, - datastoreresource.DataStoreTypeSignalFX: openapi.SIGNAL_FX, + datastoreresource.DataStoreTypeOpenSearch: openapi.OPENSEARCH, + datastoreresource.DataStoreTypeSignalFX: openapi.SIGNALFX, datastoreresource.DataStoreTypeOTLP: openapi.OTLP, - datastoreresource.DataStoreTypeNewRelic: openapi.NEW_RELIC, + datastoreresource.DataStoreTypeNewRelic: openapi.NEWRELIC, datastoreresource.DataStoreTypeLighStep: openapi.LIGHTSTEP, - datastoreresource.DataStoreTypeElasticAPM: openapi.ELASTIC_APM, + datastoreresource.DataStoreTypeElasticAPM: openapi.ELASTICAPM, datastoreresource.DataStoreTypeDataDog: openapi.DATADOG, datastoreresource.DataStoreTypeAwsXRay: openapi.AWSXRAY, } @@ -127,19 +127,19 @@ func (m Model) DataStore(in openapi.DataStore) datastoreresource.DataStore { // OpenSearch if dataStore.Type == datastoreresource.DataStoreTypeOpenSearch { dataStore.Values.OpenSearch = &datastoreresource.ElasticSearchConfig{} - deepcopy.DeepCopy(in.OpenSearch, &dataStore.Values.OpenSearch) + deepcopy.DeepCopy(in.Opensearch, &dataStore.Values.OpenSearch) } // ElasticAPM if dataStore.Type == datastoreresource.DataStoreTypeElasticAPM { dataStore.Values.OpenSearch = &datastoreresource.ElasticSearchConfig{} - deepcopy.DeepCopy(in.OpenSearch, &dataStore.Values.ElasticApm) + deepcopy.DeepCopy(in.Opensearch, &dataStore.Values.ElasticApm) } // SignalFX if dataStore.Type == datastoreresource.DataStoreTypeSignalFX { dataStore.Values.SignalFx = &datastoreresource.SignalFXConfig{} - deepcopy.DeepCopy(in.SignalFx, &dataStore.Values.SignalFx) + deepcopy.DeepCopy(in.Signalfx, &dataStore.Values.SignalFx) } return dataStore diff --git a/server/openapi/api_resource_api_service.go b/server/openapi/api_resource_api_service.go index 71efef5948..4393821ab2 100644 --- a/server/openapi/api_resource_api_service.go +++ b/server/openapi/api_resource_api_service.go @@ -93,8 +93,8 @@ func (s *ResourceApiApiService) GetDataStore(ctx context.Context, dataStoreId st // TODO - update GetDataStore with the required logic for this service method. // Add api_resource_api_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. - //TODO: Uncomment the next line to return response Response(200, DataStore{}) or use other options such as http.Ok ... - //return Response(200, DataStore{}), nil + //TODO: Uncomment the next line to return response Response(200, DataStoreResource{}) or use other options such as http.Ok ... + //return Response(200, DataStoreResource{}), nil //TODO: Uncomment the next line to return response Response(404, {}) or use other options such as http.Ok ... //return Response(404, nil),nil diff --git a/server/openapi/model_data_store.go b/server/openapi/model_data_store.go index c908e95556..e5ece88552 100644 --- a/server/openapi/model_data_store.go +++ b/server/openapi/model_data_store.go @@ -26,11 +26,11 @@ type DataStore struct { Tempo BaseClient `json:"tempo,omitempty"` - OpenSearch ElasticSearch `json:"openSearch,omitempty"` + Opensearch ElasticSearch `json:"opensearch,omitempty"` - ElasticApm ElasticSearch `json:"elasticApm,omitempty"` + Elasticapm ElasticSearch `json:"elasticapm,omitempty"` - SignalFx SignalFx `json:"signalFx,omitempty"` + Signalfx SignalFx `json:"signalfx,omitempty"` Awsxray AwsXRay `json:"awsxray,omitempty"` @@ -55,13 +55,13 @@ func AssertDataStoreRequired(obj DataStore) error { if err := AssertBaseClientRequired(obj.Tempo); err != nil { return err } - if err := AssertElasticSearchRequired(obj.OpenSearch); err != nil { + if err := AssertElasticSearchRequired(obj.Opensearch); err != nil { return err } - if err := AssertElasticSearchRequired(obj.ElasticApm); err != nil { + if err := AssertElasticSearchRequired(obj.Elasticapm); err != nil { return err } - if err := AssertSignalFxRequired(obj.SignalFx); err != nil { + if err := AssertSignalFxRequired(obj.Signalfx); err != nil { return err } if err := AssertAwsXRayRequired(obj.Awsxray); err != nil { diff --git a/server/openapi/model_data_store_resource.go b/server/openapi/model_data_store_resource.go new file mode 100644 index 0000000000..8baefee76a --- /dev/null +++ b/server/openapi/model_data_store_resource.go @@ -0,0 +1,39 @@ +/* + * TraceTest + * + * OpenAPI definition for TraceTest endpoint and resources + * + * API version: 0.2.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +// DataStoreResource - Represents a data store structured into the Resources format. +type DataStoreResource struct { + + // Represents the type of this resource. It should always be set as 'DataStore'. + Type string `json:"type,omitempty"` + + Spec DataStore `json:"spec,omitempty"` +} + +// AssertDataStoreResourceRequired checks if the required fields are not zero-ed +func AssertDataStoreResourceRequired(obj DataStoreResource) error { + if err := AssertDataStoreRequired(obj.Spec); err != nil { + return err + } + return nil +} + +// AssertRecurseDataStoreResourceRequired recursively checks if required fields are not zero-ed in a nested slice. +// Accepts only nested slice of DataStoreResource (e.g. [][]DataStoreResource), otherwise ErrTypeAssertionError is thrown. +func AssertRecurseDataStoreResourceRequired(objSlice interface{}) error { + return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error { + aDataStoreResource, ok := obj.(DataStoreResource) + if !ok { + return ErrTypeAssertionError + } + return AssertDataStoreResourceRequired(aDataStoreResource) + }) +} diff --git a/server/openapi/model_supported_data_stores.go b/server/openapi/model_supported_data_stores.go index 3bce2719d4..4c2b57eb05 100644 --- a/server/openapi/model_supported_data_stores.go +++ b/server/openapi/model_supported_data_stores.go @@ -13,16 +13,16 @@ type SupportedDataStores string // List of SupportedDataStores const ( - JAEGER SupportedDataStores = "jaeger" - OPEN_SEARCH SupportedDataStores = "openSearch" - TEMPO SupportedDataStores = "tempo" - SIGNAL_FX SupportedDataStores = "signalFx" - OTLP SupportedDataStores = "otlp" - ELASTIC_APM SupportedDataStores = "elasticApm" - NEW_RELIC SupportedDataStores = "newRelic" - LIGHTSTEP SupportedDataStores = "lightstep" - DATADOG SupportedDataStores = "datadog" - AWSXRAY SupportedDataStores = "awsxray" + JAEGER SupportedDataStores = "jaeger" + OPENSEARCH SupportedDataStores = "opensearch" + TEMPO SupportedDataStores = "tempo" + SIGNALFX SupportedDataStores = "signalfx" + OTLP SupportedDataStores = "otlp" + ELASTICAPM SupportedDataStores = "elasticapm" + NEWRELIC SupportedDataStores = "newrelic" + LIGHTSTEP SupportedDataStores = "lightstep" + DATADOG SupportedDataStores = "datadog" + AWSXRAY SupportedDataStores = "awsxray" ) // AssertSupportedDataStoresRequired checks if the required fields are not zero-ed diff --git a/server/tracedb/datastoreresource/repository_test.go b/server/tracedb/datastoreresource/repository_test.go index 0908b1b14f..3263a1dd28 100644 --- a/server/tracedb/datastoreresource/repository_test.go +++ b/server/tracedb/datastoreresource/repository_test.go @@ -155,7 +155,7 @@ func TestDataStoreResource_ElasticAPM(t *testing.T) { "type": "elasticapm", "default": true, "createdAt": "2023-03-09T17:53:10.256383Z", - "elasticApm": { + "elasticapm": { "addresses": ["1.2.3.4"], "username": "some-user", "password": "some-password", @@ -173,7 +173,7 @@ func TestDataStoreResource_ElasticAPM(t *testing.T) { "type": "elasticapm", "default": true, "createdAt": "2023-03-09T17:53:10.256383Z", - "elasticApm": { + "elasticapm": { "addresses": ["4.3.2.1"], "username": "some-user-updated", "password": "some-password-updated", @@ -319,7 +319,7 @@ func TestDataStoreResource_OpenSearch(t *testing.T) { "type": "opensearch", "default": true, "createdAt": "2023-03-09T17:53:10.256383Z", - "openSearch": { + "opensearch": { "addresses": ["1.2.3.4"], "username": "some-user", "password": "some-password", @@ -337,7 +337,7 @@ func TestDataStoreResource_OpenSearch(t *testing.T) { "type": "opensearch", "default": true, "createdAt": "2023-03-09T17:53:10.256383Z", - "openSearch": { + "opensearch": { "addresses": ["4.3.2.1"], "username": "some-user-updated", "password": "some-password-updated", @@ -380,7 +380,7 @@ func TestDataStoreResource_SignalFX(t *testing.T) { "type": "signalfx", "default": true, "createdAt": "2023-03-09T17:53:10.256383Z", - "signalFx": { + "signalfx": { "realm": "some-realm", "token": "some-token" } @@ -394,7 +394,7 @@ func TestDataStoreResource_SignalFX(t *testing.T) { "type": "signalfx", "default": true, "createdAt": "2023-03-09T17:53:10.256383Z", - "signalFx": { + "signalfx": { "realm": "some-realm-updated", "token": "some-token-updated" } diff --git a/server/tracedb/datastoreresource/resource_types.go b/server/tracedb/datastoreresource/resource_types.go index e018fae718..aa38a82f7f 100644 --- a/server/tracedb/datastoreresource/resource_types.go +++ b/server/tracedb/datastoreresource/resource_types.go @@ -24,10 +24,10 @@ type DataStore struct { type DataStoreValues struct { AwsXRay *AWSXRayConfig `mapstructure:"awsxray,omitempty"` - ElasticApm *ElasticSearchConfig `mapstructure:"elasticApm,omitempty"` + ElasticApm *ElasticSearchConfig `mapstructure:"elasticapm,omitempty"` Jaeger *GRPCClientSettings `mapstructure:"jaeger,omitempty"` - OpenSearch *ElasticSearchConfig `mapstructure:"openSearch,omitempty"` - SignalFx *SignalFXConfig `mapstructure:"signalFx,omitempty"` + OpenSearch *ElasticSearchConfig `mapstructure:"opensearch,omitempty"` + SignalFx *SignalFXConfig `mapstructure:"signalfx,omitempty"` Tempo *MultiChannelClientConfig `mapstructure:"tempo,omitempty"` } diff --git a/web/src/models/DataStore.model.ts b/web/src/models/DataStore.model.ts index 75d8a22967..374824f264 100644 --- a/web/src/models/DataStore.model.ts +++ b/web/src/models/DataStore.model.ts @@ -2,7 +2,7 @@ import {SupportedDataStores} from 'types/DataStore.types'; import {Model, TDataStoreSchemas} from 'types/Common.types'; export type TRawDataStore = TDataStoreSchemas['DataStoreResource']; -type DataStore = Model['spec'] & {otlp?: {}; newRelic?: {}; lightstep?: {}; datadog?: {}}; +type DataStore = Model['spec'] & {otlp?: {}; newrelic?: {}; lightstep?: {}; datadog?: {}}; const DataStore = ({ spec: { @@ -11,9 +11,9 @@ const DataStore = ({ type = SupportedDataStores.JAEGER, default: isDefault = false, createdAt = '', - openSearch = {}, - elasticApm = {}, - signalFx = {}, + opensearch = {}, + elasticapm = {}, + signalfx = {}, jaeger = {}, tempo = {}, awsxray = {}, @@ -24,9 +24,9 @@ const DataStore = ({ type, default: isDefault, createdAt, - openSearch, - elasticApm, - signalFx, + opensearch, + elasticapm, + signalfx, jaeger, tempo, awsxray, diff --git a/web/src/services/DataStores/SignalFx.service.ts b/web/src/services/DataStores/SignalFx.service.ts index ffc3082f3e..7f64a2302f 100644 --- a/web/src/services/DataStores/SignalFx.service.ts +++ b/web/src/services/DataStores/SignalFx.service.ts @@ -1,26 +1,26 @@ import {SupportedDataStores, TDataStoreService} from 'types/DataStore.types'; const SignalFxService = (): TDataStoreService => ({ - getRequest({dataStore: {signalFx: {realm = '', token = ''} = {}} = {}}) { + getRequest({dataStore: {signalfx: {realm = '', token = ''} = {}} = {}}) { return Promise.resolve({ type: SupportedDataStores.SignalFX, name: SupportedDataStores.SignalFX, - signalFx: { + signalfx: { realm, token, }, }); }, - validateDraft({dataStore: {signalFx: {realm = '', token = ''} = {}} = {}}) { + validateDraft({dataStore: {signalfx: {realm = '', token = ''} = {}} = {}}) { if (!realm || !token) return Promise.resolve(false); return Promise.resolve(true); }, - getInitialValues({defaultDataStore: {signalFx = {}} = {}}) { - const {realm = '', token = ''} = signalFx; + getInitialValues({defaultDataStore: {signalfx = {}} = {}}) { + const {realm = '', token = ''} = signalfx; return { - dataStore: {name: SupportedDataStores.SignalFX, type: SupportedDataStores.SignalFX, signalFx: {realm, token}}, + dataStore: {name: SupportedDataStores.SignalFX, type: SupportedDataStores.SignalFX, signalfx: {realm, token}}, dataStoreType: SupportedDataStores.SignalFX, }; }, diff --git a/web/src/types/DataStore.types.ts b/web/src/types/DataStore.types.ts index 1a38242638..3a62f8c2cb 100644 --- a/web/src/types/DataStore.types.ts +++ b/web/src/types/DataStore.types.ts @@ -14,11 +14,11 @@ export enum SupportedDataStores { JAEGER = 'jaeger', TEMPO = 'tempo', OtelCollector = 'otlp', - NewRelic = 'newRelic', + NewRelic = 'newrelic', Lightstep = 'lightstep', - OpenSearch = 'openSearch', - ElasticApm = 'elasticApm', - SignalFX = 'signalFx', + OpenSearch = 'opensearch', + ElasticApm = 'elasticapm', + SignalFX = 'signalfx', Datadog = 'datadog', AWSXRay = 'awsxray', } @@ -79,11 +79,11 @@ export interface IElasticSearch extends TRawElasticSearch { type IDataStore = DataStore & { jaeger?: IBaseClientSettings; tempo?: IBaseClientSettings; - openSearch?: IElasticSearch; - elasticApm?: IElasticSearch; + opensearch?: IElasticSearch; + elasticapm?: IElasticSearch; otlp?: {}; lightstep?: {}; - newRelic?: {}; + newrelic?: {}; datadog?: {}; }; diff --git a/web/src/types/Generated.types.ts b/web/src/types/Generated.types.ts index a5cd957d65..7b824cbbac 100644 --- a/web/src/types/Generated.types.ts +++ b/web/src/types/Generated.types.ts @@ -175,6 +175,8 @@ export interface paths { get: operations["getDataStore"]; /** Update a Data Store */ put: operations["updateDataStore"]; + /** Delete a Data Store */ + delete: operations["deleteDataStore"]; }; } @@ -1009,6 +1011,16 @@ export interface operations { }; }; }; + /** Delete a Data Store */ + deleteDataStore: { + parameters: {}; + responses: { + /** successful operation */ + 204: never; + /** problem with data store deletion */ + 500: unknown; + }; + }; } export interface external { @@ -1150,9 +1162,9 @@ export interface external { default?: boolean; jaeger?: external["dataStores.yaml"]["components"]["schemas"]["GRPCClientSettings"]; tempo?: external["dataStores.yaml"]["components"]["schemas"]["BaseClient"]; - openSearch?: external["dataStores.yaml"]["components"]["schemas"]["ElasticSearch"]; - elasticApm?: external["dataStores.yaml"]["components"]["schemas"]["ElasticSearch"]; - signalFx?: external["dataStores.yaml"]["components"]["schemas"]["SignalFX"]; + opensearch?: external["dataStores.yaml"]["components"]["schemas"]["ElasticSearch"]; + elasticapm?: external["dataStores.yaml"]["components"]["schemas"]["ElasticSearch"]; + signalfx?: external["dataStores.yaml"]["components"]["schemas"]["SignalFX"]; awsxray?: external["dataStores.yaml"]["components"]["schemas"]["AwsXRay"]; /** Format: date-time */ createdAt?: string; @@ -1222,12 +1234,12 @@ export interface external { /** @enum {string} */ SupportedDataStores: | "jaeger" - | "openSearch" + | "opensearch" | "tempo" - | "signalFx" + | "signalfx" | "otlp" - | "elasticApm" - | "newRelic" + | "elasticapm" + | "newrelic" | "lightstep" | "datadog" | "awsxray";