From 5a3b70006b9289a5bb1e63b98ba4ce10188867fc Mon Sep 17 00:00:00 2001 From: Abhishek Date: Wed, 3 Jul 2024 14:48:38 +0530 Subject: [PATCH] [feat]: [DBOPS-308]: Onboard JDBC connector (#539) --- .../nextgen/docs/JdbcAuthCredentialsDto.md | 8 ++++ harness/nextgen/docs/JdbcAuthenticationDto.md | 10 +++++ harness/nextgen/docs/JdbcConnector.md | 12 ++++++ .../nextgen/docs/JdbcUserNamePasswordDto.md | 11 +++++ harness/nextgen/enum_connector_types.go | 3 ++ harness/nextgen/enum_jdbc_auth_types.go | 13 ++++++ harness/nextgen/model_connector_info.go | 1 + .../model_connector_info_serializer.go | 4 ++ .../model_jdbc_auth_credentials_dto.go | 14 +++++++ .../nextgen/model_jdbc_authentication_dto.go | 19 +++++++++ .../model_jdbc_authentication_serializer.go | 42 +++++++++++++++++++ harness/nextgen/model_jdbc_connector.go | 19 +++++++++ .../model_jdbc_user_name_password_dto.go | 17 ++++++++ 13 files changed, 173 insertions(+) create mode 100644 harness/nextgen/docs/JdbcAuthCredentialsDto.md create mode 100644 harness/nextgen/docs/JdbcAuthenticationDto.md create mode 100644 harness/nextgen/docs/JdbcConnector.md create mode 100644 harness/nextgen/docs/JdbcUserNamePasswordDto.md create mode 100644 harness/nextgen/enum_jdbc_auth_types.go create mode 100644 harness/nextgen/model_jdbc_auth_credentials_dto.go create mode 100644 harness/nextgen/model_jdbc_authentication_dto.go create mode 100644 harness/nextgen/model_jdbc_authentication_serializer.go create mode 100644 harness/nextgen/model_jdbc_connector.go create mode 100644 harness/nextgen/model_jdbc_user_name_password_dto.go diff --git a/harness/nextgen/docs/JdbcAuthCredentialsDto.md b/harness/nextgen/docs/JdbcAuthCredentialsDto.md new file mode 100644 index 00000000..e9f02f80 --- /dev/null +++ b/harness/nextgen/docs/JdbcAuthCredentialsDto.md @@ -0,0 +1,8 @@ +# JdbcAuthCredentialsDto + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/harness/nextgen/docs/JdbcAuthenticationDto.md b/harness/nextgen/docs/JdbcAuthenticationDto.md new file mode 100644 index 00000000..a5e773ef --- /dev/null +++ b/harness/nextgen/docs/JdbcAuthenticationDto.md @@ -0,0 +1,10 @@ +# JdbcAuthenticationDto + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Type_** | **string** | | [default to null] +**Spec** | [***JdbcAuthCredentialsDto**](JDBCAuthCredentialsDTO.md) | | [optional] [default to null] + +[[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/harness/nextgen/docs/JdbcConnector.md b/harness/nextgen/docs/JdbcConnector.md new file mode 100644 index 00000000..60467095 --- /dev/null +++ b/harness/nextgen/docs/JdbcConnector.md @@ -0,0 +1,12 @@ +# JdbcConnector + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Url** | **string** | | [default to null] +**Auth** | [***JdbcAuthenticationDto**](JDBCAuthenticationDTO.md) | | [optional] [default to null] +**DelegateSelectors** | **[]string** | | [optional] [default to null] +**ConnectorType** | **string** | | [default to null] + +[[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/harness/nextgen/docs/JdbcUserNamePasswordDto.md b/harness/nextgen/docs/JdbcUserNamePasswordDto.md new file mode 100644 index 00000000..9088d83c --- /dev/null +++ b/harness/nextgen/docs/JdbcUserNamePasswordDto.md @@ -0,0 +1,11 @@ +# JdbcUserNamePasswordDto + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Username** | **string** | | [optional] [default to null] +**UsernameRef** | **string** | | [optional] [default to null] +**PasswordRef** | **string** | | [default to null] + +[[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/harness/nextgen/enum_connector_types.go b/harness/nextgen/enum_connector_types.go index 52693a68..9ff9096f 100644 --- a/harness/nextgen/enum_connector_types.go +++ b/harness/nextgen/enum_connector_types.go @@ -13,6 +13,7 @@ var ConnectorTypes = struct { Vault ConnectorType AzureKeyVault ConnectorType DockerRegistry ConnectorType + JDBC ConnectorType Local ConnectorType AwsKms ConnectorType GcpKms ConnectorType @@ -57,6 +58,7 @@ var ConnectorTypes = struct { Vault: "Vault", AzureKeyVault: "AzureKeyVault", DockerRegistry: "DockerRegistry", + JDBC: "JDBC", Local: "Local", AwsKms: "AwsKms", GcpKms: "GcpKms", @@ -104,6 +106,7 @@ var ConnectorTypesSlice = []string{ ConnectorTypes.Vault.String(), ConnectorTypes.AzureKeyVault.String(), ConnectorTypes.DockerRegistry.String(), + ConnectorTypes.JDBC.String(), ConnectorTypes.Local.String(), ConnectorTypes.AwsKms.String(), ConnectorTypes.GcpKms.String(), diff --git a/harness/nextgen/enum_jdbc_auth_types.go b/harness/nextgen/enum_jdbc_auth_types.go new file mode 100644 index 00000000..5ae68483 --- /dev/null +++ b/harness/nextgen/enum_jdbc_auth_types.go @@ -0,0 +1,13 @@ +package nextgen + +type JDBCAuthType string + +var JDBCAuthTypes = struct { + UsernamePassword JDBCAuthType +}{ + UsernamePassword: "UsernamePassword", +} + +func (e JDBCAuthType) String() string { + return string(e) +} diff --git a/harness/nextgen/model_connector_info.go b/harness/nextgen/model_connector_info.go index 6522d1a9..d2e70340 100644 --- a/harness/nextgen/model_connector_info.go +++ b/harness/nextgen/model_connector_info.go @@ -43,6 +43,7 @@ type ConnectorInfo struct { CustomSecretManager *CustomSecretManager `json:"_"` Datadog *DatadogConnectorDto `json:"-"` DockerRegistry *DockerConnector `json:"-"` + JDBC *JdbcConnector `json:"-"` Dynatrace *DynatraceConnectorDto `json:"-"` Gcp *GcpConnector `json:"-"` GcpCloudCost *GcpCloudCostConnectorDto `json:"-"` diff --git a/harness/nextgen/model_connector_info_serializer.go b/harness/nextgen/model_connector_info_serializer.go index 47fa9dd9..7d01145e 100644 --- a/harness/nextgen/model_connector_info_serializer.go +++ b/harness/nextgen/model_connector_info_serializer.go @@ -49,6 +49,8 @@ func (a *ConnectorInfo) UnmarshalJSON(data []byte) error { err = json.Unmarshal(aux.Spec, &a.Datadog) case ConnectorTypes.DockerRegistry: err = json.Unmarshal(aux.Spec, &a.DockerRegistry) + case ConnectorTypes.JDBC: + err = json.Unmarshal(aux.Spec, &a.JDBC) case ConnectorTypes.Dynatrace: err = json.Unmarshal(aux.Spec, &a.Dynatrace) case ConnectorTypes.Gcp: @@ -137,6 +139,8 @@ func (a *ConnectorInfo) MarshalJSON() ([]byte, error) { spec, err = json.Marshal(a.Datadog) case ConnectorTypes.DockerRegistry: spec, err = json.Marshal(a.DockerRegistry) + case ConnectorTypes.JDBC: + spec, err = json.Marshal(a.JDBC) case ConnectorTypes.Dynatrace: spec, err = json.Marshal(a.Dynatrace) case ConnectorTypes.Gcp: diff --git a/harness/nextgen/model_jdbc_auth_credentials_dto.go b/harness/nextgen/model_jdbc_auth_credentials_dto.go new file mode 100644 index 00000000..0ac19516 --- /dev/null +++ b/harness/nextgen/model_jdbc_auth_credentials_dto.go @@ -0,0 +1,14 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * This is the Open Api Spec 3 for the NextGen Manager. This is under active development. Beware of the breaking change with respect to the generated code stub + * + * API version: 3.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +// This contains details of credentials for JDBC Authentication +type JdbcAuthCredentialsDto struct { +} diff --git a/harness/nextgen/model_jdbc_authentication_dto.go b/harness/nextgen/model_jdbc_authentication_dto.go new file mode 100644 index 00000000..31c793d6 --- /dev/null +++ b/harness/nextgen/model_jdbc_authentication_dto.go @@ -0,0 +1,19 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * This is the Open Api Spec 3 for the NextGen Manager. This is under active development. Beware of the breaking change with respect to the generated code stub + * + * API version: 3.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +import "encoding/json" + +// This entity contains the details for JDBC Authentication +type JdbcAuthenticationDto struct { + Type_ JDBCAuthType `json:"type"` + UsernamePassword *JdbcUserNamePasswordDto `json:"-"` + Spec json.RawMessage `json:"spec,omitempty"` +} diff --git a/harness/nextgen/model_jdbc_authentication_serializer.go b/harness/nextgen/model_jdbc_authentication_serializer.go new file mode 100644 index 00000000..878df152 --- /dev/null +++ b/harness/nextgen/model_jdbc_authentication_serializer.go @@ -0,0 +1,42 @@ +package nextgen + +import ( + "encoding/json" +) + +func (a *JdbcAuthenticationDto) UnmarshalJSON(data []byte) error { + + type Alias JdbcAuthenticationDto + + aux := &struct { + *Alias + }{ + Alias: (*Alias)(a), + } + + err := json.Unmarshal(data, &aux) + if err != nil { + return err + } + + err = json.Unmarshal(aux.Spec, &a.UsernamePassword) + + return err +} + +func (a *JdbcAuthenticationDto) MarshalJSON() ([]byte, error) { + type Alias JdbcAuthenticationDto + + var spec []byte + var err error + + spec, err = json.Marshal(a.UsernamePassword) + + if err != nil { + return nil, err + } + + a.Spec = json.RawMessage(spec) + + return json.Marshal((*Alias)(a)) +} diff --git a/harness/nextgen/model_jdbc_connector.go b/harness/nextgen/model_jdbc_connector.go new file mode 100644 index 00000000..d8442630 --- /dev/null +++ b/harness/nextgen/model_jdbc_connector.go @@ -0,0 +1,19 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * This is the Open Api Spec 3 for the NextGen Manager. This is under active development. Beware of the breaking change with respect to the generated code stub + * + * API version: 3.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +// This contains details of the JDBC connector +type JdbcConnector struct { + Url string `json:"url"` + Auth *JdbcAuthenticationDto `json:"auth,omitempty"` + DelegateSelectors []string `json:"delegateSelectors,omitempty"` + ConnectorType string `json:"connectorType"` + ExecuteOnDelegate bool `json:"executeOnDelegate"` +} diff --git a/harness/nextgen/model_jdbc_user_name_password_dto.go b/harness/nextgen/model_jdbc_user_name_password_dto.go new file mode 100644 index 00000000..9a027572 --- /dev/null +++ b/harness/nextgen/model_jdbc_user_name_password_dto.go @@ -0,0 +1,17 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * This is the Open Api Spec 3 for the NextGen Manager. This is under active development. Beware of the breaking change with respect to the generated code stub + * + * API version: 3.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +// This entity contains the details of the JDBC Username and Password +type JdbcUserNamePasswordDto struct { + Username string `json:"username,omitempty"` + UsernameRef string `json:"usernameRef,omitempty"` + PasswordRef string `json:"passwordRef"` +}