diff --git a/connectors/connector_auth.go b/connectors/connector_auth.go index 0643009e..5b14ee37 100644 --- a/connectors/connector_auth.go +++ b/connectors/connector_auth.go @@ -5,17 +5,43 @@ import "github.com/fivetran/go-fivetran/utils" // ConnectorAuth builds Connector Management, Auth. // Ref. https://fivetran.com/docs/rest-api/connectors type ConnectorAuth struct { - clientAccess *ConnectorAuthClientAccess - refreshToken *string - accessToken *string - realmID *string + clientAccess *ConnectorAuthClientAccess + refreshToken *string + accessToken *string + realmID *string + previousRefreshToken *string + userAccessToken *string + consumerSecret *string + consumerKey *string + oauthToken *string + oauthTokenSecret *string + roleArn *string + awsAccessKey *string + awsSecretKey *string + clientId *string + keyId *string + teamId *string + clientSecret *string } type connectorAuthRequest struct { - ClientAccess *connectorAuthClientAccessRequest `json:"client_access,omitempty"` - RefreshToken *string `json:"refresh_token,omitempty"` - AccessToken *string `json:"access_token,omitempty"` - RealmID *string `json:"realm_id,omitempty"` + ClientAccess *connectorAuthClientAccessRequest `json:"client_access,omitempty"` + RefreshToken *string `json:"refresh_token,omitempty"` + AccessToken *string `json:"access_token,omitempty"` + RealmID *string `json:"realm_id,omitempty"` + PreviousRefreshToken *string `json:"previous_refresh_token,omitempty"` + UserAccessToken *string `json:"user_access_token,omitempty"` + ConsumerSecret *string `json:"consumer_secret,omitempty"` + ConsumerKey *string `json:"consumer_key,omitempty"` + OauthToken *string `json:"oauth_token,omitempty"` + OauthTokenSecret *string `json:"oauth_token_secret,omitempty"` + RoleArn *string `json:"role_arn,omitempty"` + AwsAccessKey *string `json:"aws_access_key,omitempty"` + AwsSecretKey *string `json:"aws_secret_key,omitempty"` + ClientId *string `json:"client_id,omitempty"` + KeyId *string `json:"key_id,omitempty"` + TeamId *string `json:"team_id,omitempty"` + ClientSecret *string `json:"client_secret,omitempty"` } func (ca *ConnectorAuth) Merge(customAuth *map[string]interface{}) (*map[string]interface{}, error) { @@ -33,10 +59,23 @@ func (ca *ConnectorAuth) Request() *connectorAuthRequest { } return &connectorAuthRequest{ - ClientAccess: clientAccess, - RefreshToken: ca.refreshToken, - AccessToken: ca.accessToken, - RealmID: ca.realmID, + ClientAccess: clientAccess, + RefreshToken: ca.refreshToken, + AccessToken: ca.accessToken, + RealmID: ca.realmID, + PreviousRefreshToken: ca.previousRefreshToken, + UserAccessToken: ca.userAccessToken, + ConsumerSecret: ca.consumerSecret, + ConsumerKey: ca.consumerKey, + OauthToken: ca.oauthToken, + OauthTokenSecret: ca.oauthTokenSecret, + RoleArn: ca.roleArn, + AwsAccessKey: ca.awsAccessKey, + AwsSecretKey: ca.awsSecretKey, + ClientId: ca.clientId, + KeyId: ca.keyId, + TeamId: ca.teamId, + ClientSecret: ca.clientSecret, } } @@ -59,3 +98,68 @@ func (ca *ConnectorAuth) RealmID(value string) *ConnectorAuth { ca.realmID = &value return ca } + +func (ca *ConnectorAuth) PreviousRefreshToken(value string) *ConnectorAuth { + ca.previousRefreshToken = &value + return ca +} + +func (ca *ConnectorAuth) UserAccessToken(value string) *ConnectorAuth { + ca.userAccessToken = &value + return ca +} + +func (ca *ConnectorAuth) ConsumerSecret(value string) *ConnectorAuth { + ca.consumerSecret = &value + return ca +} + +func (ca *ConnectorAuth) ConsumerKey(value string) *ConnectorAuth { + ca.consumerKey = &value + return ca +} + +func (ca *ConnectorAuth) OauthToken(value string) *ConnectorAuth { + ca.oauthToken = &value + return ca +} + +func (ca *ConnectorAuth) OauthTokenSecret(value string) *ConnectorAuth { + ca.oauthTokenSecret = &value + return ca +} + +func (ca *ConnectorAuth) RoleArn(value string) *ConnectorAuth { + ca.roleArn = &value + return ca +} + +func (ca *ConnectorAuth) AwsAccessKey(value string) *ConnectorAuth { + ca.awsAccessKey = &value + return ca +} + +func (ca *ConnectorAuth) AwsSecretKey(value string) *ConnectorAuth { + ca.awsSecretKey = &value + return ca +} + +func (ca *ConnectorAuth) ClientId(value string) *ConnectorAuth { + ca.clientId = &value + return ca +} + +func (ca *ConnectorAuth) KeyId(value string) *ConnectorAuth { + ca.keyId = &value + return ca +} + +func (ca *ConnectorAuth) TeamId(value string) *ConnectorAuth { + ca.teamId = &value + return ca +} + +func (ca *ConnectorAuth) ClientSecret(value string) *ConnectorAuth { + ca.clientSecret = &value + return ca +} \ No newline at end of file diff --git a/destinations/destination_config.go b/destinations/destination_config.go index 13682c96..9c6ddc7f 100644 --- a/destinations/destination_config.go +++ b/destinations/destination_config.go @@ -39,6 +39,8 @@ type DestinationConfig struct { tenantId *string clientId *string secretValue *string + workspaceName *string + lakehouseName *string } type destinationConfigRequest struct { @@ -78,6 +80,8 @@ type destinationConfigRequest struct { TenantId *string `json:"tenant_id,omitempty"` ClientId *string `json:"client_id,omitempty"` SecretValue *string `json:"secret_value,omitempty"` + WorkspaceName *string `json:"workspace_name,omitempty"` + LakehouseName *string `json:"lakehouse_name,omitempty"` } type DestinationConfigResponse struct { @@ -119,6 +123,8 @@ type DestinationConfigResponse struct { TenantId string `json:"tenant_id"` ClientId string `json:"client_id"` SecretValue string `json:"secret_value"` + WorkspaceName string `json:"workspace_name"` + LakehouseName string `json:"lakehouse_name"` } func (dc *DestinationConfig) Request() *destinationConfigRequest { @@ -159,6 +165,8 @@ func (dc *DestinationConfig) Request() *destinationConfigRequest { TenantId: dc.tenantId, ClientId: dc.clientId, SecretValue: dc.secretValue, + WorkspaceName: dc.workspaceName, + LakehouseName: dc.lakehouseName, } } @@ -345,4 +353,14 @@ func (dc *DestinationConfig) ClientId(value string) *DestinationConfig { func (dc *DestinationConfig) SecretValue(value string) *DestinationConfig { dc.secretValue = &value return dc +} + +func (dc *DestinationConfig) WorkspaceName(value string) *DestinationConfig { + dc.workspaceName = &value + return dc +} + +func (dc *DestinationConfig) LakehouseName(value string) *DestinationConfig { + dc.lakehouseName = &value + return dc } \ No newline at end of file diff --git a/examples/connectorCreate-2/main.go b/examples/connectorCreate-2/main.go index 95066a57..40089b78 100644 --- a/examples/connectorCreate-2/main.go +++ b/examples/connectorCreate-2/main.go @@ -51,7 +51,20 @@ func main() { connAuth.ClientAccess(connAuthClientAccess). AccessToken("thisIsAccessToken"). RealmID("thisIsRealmID"). - RefreshToken("thisIsRefreshToken") + RefreshToken("thisIsRefreshToken"). + PreviousRefreshToken("thisIsPreviousRefreshToken"). + UserAccessToken("thisIsUserAccessToken"). + ConsumerSecret("thisIsConsumerSecret"). + ConsumerKey("thisIsConsumerKey"). + OauthToken("thisIsOauthToken"). + OauthTokenSecret("thisIsOauthTokenSecret"). + RoleArn("thisIsRoleArn"). + AwsAccessKey("thisIsAwsAccessKey"). + AwsSecretKey("thisIsAwsSecretKey"). + ClientId("thisIsClientId"). + KeyId("thisIsKeyId"). + TeamId("thisIsTeamId"). + ClientSecret("thisIsClientSecret") svc.GroupID("replying_ministry") svc.Service("google_sheets") diff --git a/examples/destinationCreate/main.go b/examples/destinationCreate/main.go index 5009e65e..a7d95dc6 100644 --- a/examples/destinationCreate/main.go +++ b/examples/destinationCreate/main.go @@ -28,7 +28,7 @@ func main() { svc.GroupID("anyplace_silvery") svc.Service("snowflake") - svc.Region("US") + svc.Region("GCP_US_EAST4") svc.TimeZoneOffset("-5") svc.Config(destConfig) diff --git a/test_utils/test_utils.go b/test_utils/test_utils.go index 4939781a..8888795b 100644 --- a/test_utils/test_utils.go +++ b/test_utils/test_utils.go @@ -73,7 +73,7 @@ func CreateDbtDestination(t *testing.T) { destination, err := Client.NewDestinationCreate(). GroupID(PredefinedGroupId). Service("big_query"). - Region("US"). + Region("GCP_US_EAST4"). RunSetupTests(true). TimeZoneOffset("-5"). Config( diff --git a/tests/destination_create_mock_test.go b/tests/destination_create_mock_test.go index e6c25d91..ec105f63 100644 --- a/tests/destination_create_mock_test.go +++ b/tests/destination_create_mock_test.go @@ -62,6 +62,8 @@ const ( TENANT_ID = "tenant_id" CLIENT_ID = "client_id" SECRET_VALUE = "secret_value" + WORKSPACE_NAME = "workspace_name" + LAKEHOUSE_NAME = "lakehouse_name" ) func TestNewDestinationCreateFullMappingMock(t *testing.T) { @@ -157,7 +159,9 @@ func prepareDestinationResponse() string { "container_name": "%v", "tenant_id": "%v", "client_id": "%v", - "secret_value": "%v" + "secret_value": "%v", + "workspace_name": "%v", + "lakehouse_name": "%v" } } }`, @@ -208,6 +212,8 @@ func prepareDestinationResponse() string { TENANT_ID, CLIENT_ID, SECRET_VALUE, + WORKSPACE_NAME, + LAKEHOUSE_NAME, ) } @@ -248,6 +254,8 @@ func prepareConfig() *destinations.DestinationConfig { config.TenantId(TENANT_ID) config.ClientId(CLIENT_ID) config.SecretValue(SECRET_VALUE) + config.WorkspaceName(WORKSPACE_NAME) + config.LakehouseName(LAKEHOUSE_NAME) return config } @@ -301,6 +309,8 @@ func assertRequest(t *testing.T, request map[string]interface{}) { assertKey(t, "tenant_id", config, TENANT_ID) assertKey(t, "client_id", config, CLIENT_ID) assertKey(t, "secret_value", config, SECRET_VALUE) + assertKey(t, "workspace_name", config, WORKSPACE_NAME) + assertKey(t, "lakehouse_name", config, LAKEHOUSE_NAME) } func assertResponse(t *testing.T, response destinations.DestinationDetailsWithSetupTestsResponse) { @@ -358,4 +368,6 @@ func assertResponse(t *testing.T, response destinations.DestinationDetailsWithSe assertEqual(t, response.Data.Config.TenantId, TENANT_ID) assertEqual(t, response.Data.Config.ClientId, CLIENT_ID) assertEqual(t, response.Data.Config.SecretValue, SECRET_VALUE) + assertEqual(t, response.Data.Config.WorkspaceName, WORKSPACE_NAME) + assertEqual(t, response.Data.Config.LakehouseName, LAKEHOUSE_NAME) }