From fc07150fd738f0c25a0f8fc67d2f6b4521beb74f Mon Sep 17 00:00:00 2001 From: Vuong Date: Mon, 29 Jul 2024 16:10:47 +0800 Subject: [PATCH] remove apierr with corresponding sdk structs --- access/resource_ip_access_list_test.go | 12 +++---- aws/resource_group_instance_profile_test.go | 14 ++++---- aws/resource_instance_profile_test.go | 10 +++--- aws/resource_service_principal_role_test.go | 6 ++-- aws/resource_user_instance_profile_test.go | 10 +++--- catalog/resource_artifact_allowlist_test.go | 10 +++--- catalog/resource_connection_test.go | 10 +++--- catalog/resource_external_location_test.go | 8 ++--- catalog/resource_storage_credential_test.go | 4 +-- catalog/resource_system_schema_test.go | 10 +++--- catalog/resource_volume_test.go | 18 +++++----- clusters/clusters_api_sdk_test.go | 4 +-- clusters/clusters_api_test.go | 8 ++--- clusters/resource_cluster_test.go | 12 +++---- common/apierr.go | 30 ---------------- jobs/data_job_test.go | 4 +-- jobs/resource_job_test.go | 6 ++-- mlflow/data_mlflow_experiment_test.go | 8 ++--- mlflow/data_mlflow_model_test.go | 4 +-- mws/resource_mws_credentials_test.go | 10 +++--- ...resource_mws_customer_managed_keys_test.go | 6 ++-- mws/resource_mws_log_delivery_test.go | 10 +++--- mws/resource_mws_networks_test.go | 12 +++---- ...esource_mws_storage_configurations_test.go | 10 +++--- mws/resource_mws_vpc_endpoint_test.go | 12 +++---- mws/resource_mws_workspaces_test.go | 16 ++++----- .../resource_access_control_rule_set_test.go | 4 +-- permissions/resource_permissions_test.go | 12 +++---- pipelines/resource_pipeline_test.go | 18 +++++----- policies/resource_cluster_policy_test.go | 18 +++++----- pools/resource_instance_pool_test.go | 12 +++---- provider/generate_test.go | 10 +++--- repos/resource_git_credential_test.go | 20 +++++------ repos/resource_repo_test.go | 6 ++-- scim/resource_entitlement_test.go | 34 +++++++++---------- scim/resource_group_member_test.go | 10 +++--- scim/resource_group_role_test.go | 10 +++--- scim/resource_group_test.go | 10 +++--- scim/resource_service_principal.go | 2 +- scim/resource_service_principal_test.go | 10 +++--- scim/resource_user.go | 2 +- scim/resource_user_test.go | 13 +++---- secrets/resource_secret_acl_test.go | 10 +++--- secrets/resource_secret_scope_test.go | 8 ++--- secrets/resource_secret_test.go | 8 ++--- serving/resource_model_serving_test.go | 12 +++---- sharing/resource_recipient_test.go | 6 ++-- sharing/resource_share_test.go | 8 ++--- storage/resource_file_test.go | 6 ++-- tokens/resource_token_test.go | 7 ++-- workspace/resource_directory_test.go | 12 +++---- workspace/resource_global_init_script_test.go | 4 +-- workspace/resource_notebook_test.go | 12 +++---- workspace/resource_workspace_conf_test.go | 12 +++---- workspace/resource_workspace_file_test.go | 12 +++---- 55 files changed, 271 insertions(+), 301 deletions(-) delete mode 100644 common/apierr.go diff --git a/access/resource_ip_access_list_test.go b/access/resource_ip_access_list_test.go index 8970493f92..35fe12dea6 100644 --- a/access/resource_ip_access_list_test.go +++ b/access/resource_ip_access_list_test.go @@ -8,8 +8,8 @@ import ( "net/http" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/settings" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" @@ -93,7 +93,7 @@ func TestAPIACLCreate_Error(t *testing.T) { { Method: http.MethodPost, Resource: "/api/2.0/ip-access-lists", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_ALREADY_EXISTS", Message: "IP access list with type (" + TestingListTypeString + ") and label (" + TestingLabel + ") already exists", }, @@ -185,7 +185,7 @@ func TestIPACLUpdate_Error(t *testing.T) { ExpectedRequest: settings.UpdateIpAccessList{ Enabled: TestingEnabled, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -240,7 +240,7 @@ func TestIPACLRead_NotFound(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.0/ip-access-lists/" + TestingId + "?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Can't find an IP access list with id: " + TestingId + ".", }, @@ -260,7 +260,7 @@ func TestIPACLRead_Error(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.0/ip-access-lists/" + TestingId + "?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -298,7 +298,7 @@ func TestIPACLDelete_Error(t *testing.T) { { Method: http.MethodDelete, Resource: fmt.Sprintf("/api/2.0/ip-access-lists/%s?", TestingId), - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_STATE", Message: "Something went wrong", }, diff --git a/aws/resource_group_instance_profile_test.go b/aws/resource_group_instance_profile_test.go index 6b96a34b41..20a0eb6f30 100644 --- a/aws/resource_group_instance_profile_test.go +++ b/aws/resource_group_instance_profile_test.go @@ -3,7 +3,7 @@ package aws import ( "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/scim" "github.com/databricks/terraform-provider-databricks/qa" @@ -56,7 +56,7 @@ func TestResourceGroupInstanceProfileCreate_Error(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/preview/scim/v2/Groups/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -80,7 +80,7 @@ func TestResourceGroupInstanceProfileCreate_Error_InvalidARN(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/preview/scim/v2/Groups/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -103,7 +103,7 @@ func TestResourceGroupInstanceProfileCreate_Error_OtherARN(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/preview/scim/v2/Groups/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -152,7 +152,7 @@ func TestResourceGroupInstanceProfileRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=roles", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -192,7 +192,7 @@ func TestResourceGroupInstanceProfileRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=roles", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -232,7 +232,7 @@ func TestResourceGroupInstanceProfileDelete_Error(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/preview/scim/v2/Groups/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/aws/resource_instance_profile_test.go b/aws/resource_instance_profile_test.go index ba6eb99414..ff7abfbb5f 100644 --- a/aws/resource_instance_profile_test.go +++ b/aws/resource_instance_profile_test.go @@ -3,7 +3,7 @@ package aws import ( "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" @@ -114,7 +114,7 @@ func TestResourceInstanceProfileCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/instance-profiles/add", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -249,7 +249,7 @@ func TestResourceInstanceProfileRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/instance-profiles/list", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -289,7 +289,7 @@ func TestResourceInstanceProfileDelete_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/instance-profiles/remove", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -356,7 +356,7 @@ func TestResourceInstanceProfileUpdate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/instance-profiles/edit", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/aws/resource_service_principal_role_test.go b/aws/resource_service_principal_role_test.go index 5ce5747ff0..f0a1150a7c 100644 --- a/aws/resource_service_principal_role_test.go +++ b/aws/resource_service_principal_role_test.go @@ -3,7 +3,7 @@ package aws import ( "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/scim" "github.com/databricks/terraform-provider-databricks/qa" @@ -53,7 +53,7 @@ func TestResourceServicePrincipalRoleCreate_Error(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/preview/scim/v2/ServicePrincipals/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -119,7 +119,7 @@ func TestResourceServicePrincipalRoleRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/preview/scim/v2/ServicePrincipals/abc?attributes=roles", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, diff --git a/aws/resource_user_instance_profile_test.go b/aws/resource_user_instance_profile_test.go index 795a579bfb..d790f5fb30 100644 --- a/aws/resource_user_instance_profile_test.go +++ b/aws/resource_user_instance_profile_test.go @@ -3,7 +3,7 @@ package aws import ( "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/scim" "github.com/databricks/terraform-provider-databricks/qa" @@ -68,7 +68,7 @@ func TestResourceUserInstanceProfileCreate_Error(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/preview/scim/v2/Users/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -138,7 +138,7 @@ func TestResourceUserInstanceProfileRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Users/abc?attributes=roles", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -158,7 +158,7 @@ func TestResourceUserInstanceProfileRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Users/abc?attributes=roles", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -198,7 +198,7 @@ func TestResourceUserInstanceProfileDelete_Error(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/preview/scim/v2/Users/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/catalog/resource_artifact_allowlist_test.go b/catalog/resource_artifact_allowlist_test.go index 25b5e9526e..5fd89ceb5b 100644 --- a/catalog/resource_artifact_allowlist_test.go +++ b/catalog/resource_artifact_allowlist_test.go @@ -4,8 +4,8 @@ import ( "net/http" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -105,7 +105,7 @@ func TestArtifactAllowlistCreate_Error(t *testing.T) { Method: http.MethodPut, Resource: "/api/2.1/unity-catalog/artifact-allowlists/INIT_SCRIPT", ExpectedRequest: setArtifact, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -156,7 +156,7 @@ func TestResourceArtifactAllowlistRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.1/unity-catalog/artifact-allowlists/INIT_SCRIPT?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -219,7 +219,7 @@ func TestArtifactAllowlistUpdate_Error(t *testing.T) { Method: http.MethodPut, Resource: "/api/2.1/unity-catalog/artifact-allowlists/INIT_SCRIPT", ExpectedRequest: updateArtifact, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -280,7 +280,7 @@ func TestArtifactAllowlistDelete_Error(t *testing.T) { ArtifactType: catalog.ArtifactTypeInitScript, ArtifactMatchers: []catalog.ArtifactMatcher{}, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_STATE", Message: "Something went wrong", }, diff --git a/catalog/resource_connection_test.go b/catalog/resource_connection_test.go index 2d7a1726eb..6a6279f5e3 100644 --- a/catalog/resource_connection_test.go +++ b/catalog/resource_connection_test.go @@ -4,8 +4,8 @@ import ( "net/http" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -145,7 +145,7 @@ func TestConnectionsCreate_Error(t *testing.T) { "host": "test.com", }, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -210,7 +210,7 @@ func TestConnectionRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.1/unity-catalog/connections/testConnectionName?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -395,7 +395,7 @@ func TestConnectionUpdate_Error(t *testing.T) { "host": "test.com", }, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -443,7 +443,7 @@ func TestConnectionDelete_Error(t *testing.T) { { Method: http.MethodDelete, Resource: "/api/2.1/unity-catalog/connections/testConnectionName?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_STATE", Message: "Something went wrong", }, diff --git a/catalog/resource_external_location_test.go b/catalog/resource_external_location_test.go index 26493c1005..25bfd31c0f 100644 --- a/catalog/resource_external_location_test.go +++ b/catalog/resource_external_location_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/experimental/mocks" "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/mock" ) @@ -450,7 +450,7 @@ func TestUpdateExternalLocationRollback(t *testing.T) { Url: "s3://foo/bar", CredentialName: "xyz", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -514,7 +514,7 @@ func TestUpdateExternalLocationRollbackError(t *testing.T) { Url: "s3://foo/bar", CredentialName: "xyz", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -526,7 +526,7 @@ func TestUpdateExternalLocationRollbackError(t *testing.T) { ExpectedRequest: catalog.UpdateExternalLocation{ Owner: "administrators", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/catalog/resource_storage_credential_test.go b/catalog/resource_storage_credential_test.go index f54ef401e0..b3d0837bc1 100644 --- a/catalog/resource_storage_credential_test.go +++ b/catalog/resource_storage_credential_test.go @@ -3,9 +3,9 @@ package catalog import ( "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/experimental/mocks" "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/mock" ) @@ -506,7 +506,7 @@ func TestUpdateStorageCredentialsRollback(t *testing.T) { RoleArn: "CHANGED", }, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, diff --git a/catalog/resource_system_schema_test.go b/catalog/resource_system_schema_test.go index e576eec072..03032eae69 100644 --- a/catalog/resource_system_schema_test.go +++ b/catalog/resource_system_schema_test.go @@ -4,8 +4,8 @@ import ( "net/http" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -72,7 +72,7 @@ func TestSystemSchemaCreate_Error(t *testing.T) { { Method: http.MethodPut, Resource: "/api/2.1/unity-catalog/metastores/abc/systemschemas/access", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -157,7 +157,7 @@ func TestSystemSchemaUpdate_Error(t *testing.T) { { Method: http.MethodPut, Resource: "/api/2.1/unity-catalog/metastores/abc/systemschemas/access", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -224,7 +224,7 @@ func TestSystemSchemaRead_Error(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.1/unity-catalog/metastores/abc/systemschemas?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -282,7 +282,7 @@ func TestSystemSchemaDelete_Error(t *testing.T) { { Method: http.MethodDelete, Resource: "/api/2.1/unity-catalog/metastores/abc/systemschemas/access?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/catalog/resource_volume_test.go b/catalog/resource_volume_test.go index 6cdf9c4cd6..4028984e59 100644 --- a/catalog/resource_volume_test.go +++ b/catalog/resource_volume_test.go @@ -6,8 +6,8 @@ import ( "net/http" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -154,7 +154,7 @@ func TestVolumesCreateWithoutInitialOwner_Error(t *testing.T) { { Method: http.MethodPost, Resource: "/api/2.1/unity-catalog/volumes", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -216,7 +216,7 @@ func TestVolumesCreateWithInitialOwner_Error(t *testing.T) { { Method: http.MethodPatch, Resource: "/api/2.1/unity-catalog/volumes/testCatalogName.testSchemaName.testName", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -279,7 +279,7 @@ func TestResourceVolumeRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.1/unity-catalog/volumes/testCatalogName.testSchemaName.testName?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -574,7 +574,7 @@ func TestVolumesUpdateRollback(t *testing.T) { Name: "testName", Comment: "This is a new test comment.", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -628,7 +628,7 @@ func TestVolumesUpdateRollback_Error(t *testing.T) { Name: "testName", Comment: "This is a new test comment.", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: serverErrMessage, }, @@ -640,7 +640,7 @@ func TestVolumesUpdateRollback_Error(t *testing.T) { ExpectedRequest: catalog.UpdateVolumeRequestContent{ Owner: "testOwnerOld", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: rollbackErrMessage, }, @@ -678,7 +678,7 @@ func TestVolumeUpdate_Error(t *testing.T) { ExpectedRequest: catalog.UpdateVolumeRequestContent{ Owner: "testOwnerNew", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -727,7 +727,7 @@ func TestVolumeDelete_Error(t *testing.T) { { Method: http.MethodDelete, Resource: "/api/2.1/unity-catalog/volumes/testCatalogName.testSchemaName.testName?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_STATE", Message: "Something went wrong", }, diff --git a/clusters/clusters_api_sdk_test.go b/clusters/clusters_api_sdk_test.go index ade90472c7..85c6f3229e 100644 --- a/clusters/clusters_api_sdk_test.go +++ b/clusters/clusters_api_sdk_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -144,7 +144,7 @@ func TestStartClusterAndGetInfo_StartingError(t *testing.T) { ExpectedRequest: ClusterID{ ClusterID: "abc", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ Message: "I am a teapot!", }, Status: 418, diff --git a/clusters/clusters_api_test.go b/clusters/clusters_api_test.go index b30f7498b4..13f0e00735 100644 --- a/clusters/clusters_api_test.go +++ b/clusters/clusters_api_test.go @@ -174,7 +174,7 @@ func TestWaitForClusterStatus_RetryOnNotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/clusters/get?cluster_id=abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ Message: "Nope", }, Status: 404, @@ -204,7 +204,7 @@ func TestWaitForClusterStatus_StopRetryingEarly(t *testing.T) { { Method: "GET", Resource: "/api/2.0/clusters/get?cluster_id=abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ Message: "I am a teapot", }, Status: 418, @@ -643,7 +643,7 @@ func TestStartAndGetInfo_StartingError(t *testing.T) { ExpectedRequest: ClusterID{ ClusterID: "abc", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ Message: "I am a teapot!", }, Status: 418, @@ -680,7 +680,7 @@ func TestPermanentDelete_Pinned(t *testing.T) { ExpectedRequest: ClusterID{ ClusterID: "abc", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ Message: "unpin the cluster first", }, Status: 400, diff --git a/clusters/resource_cluster_test.go b/clusters/resource_cluster_test.go index 40f8a2db62..abca8551f3 100644 --- a/clusters/resource_cluster_test.go +++ b/clusters/resource_cluster_test.go @@ -5,8 +5,8 @@ import ( "strings" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -438,7 +438,7 @@ func TestResourceClusterCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.1/clusters/create", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -518,7 +518,7 @@ func TestResourceClusterRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.1/clusters/get?cluster_id=abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ // clusters API is not fully restful, so let's test for that // TODO: https://github.com/databricks/terraform-provider-databricks/issues/2021 ErrorCode: "INVALID_STATE", @@ -540,7 +540,7 @@ func TestResourceClusterRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.1/clusters/get?cluster_id=abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -1226,7 +1226,7 @@ func TestResourceClusterUpdate_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.1/clusters/get?cluster_id=abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -1382,7 +1382,7 @@ func TestResourceClusterDelete_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.1/clusters/permanent-delete", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/common/apierr.go b/common/apierr.go deleted file mode 100644 index 8417f88879..0000000000 --- a/common/apierr.go +++ /dev/null @@ -1,30 +0,0 @@ -package common - -// APIErrorBody represents an API error returned by Databricks API. -// -// Deprecated: this class is meant to disappear as the Terraform provider -// progressively moves to use the service clients provided by the SDK. Clients -// should not use this class for any other purpose than testing code that -// mocks the behavior of Databricks services. -type APIErrorBody struct { - ErrorCode string `json:"error_code,omitempty"` - Message string `json:"message,omitempty"` - Details []ErrorDetail `json:"details,omitempty"` - ScimDetail string `json:"detail,omitempty"` - ScimStatus string `json:"status,omitempty"` - ScimType string `json:"scimType,omitempty"` - API12Error string `json:"error,omitempty"` -} - -// ErrorDetail represents the details of an API error. -// -// Deprecated: this struct is meant to disappear as the Terraform provider -// progressively moves to use the service clients provided by the SDK. Clients -// should not use this struct for any other purpose than testing code that -// mocks the behavior of Databricks services. -type ErrorDetail struct { - Type string `json:"@type,omitempty"` - Reason string `json:"reason,omitempty"` - Domain string `json:"domain,omitempty"` - Metadata map[string]string `json:"metadata,omitempty"` -} diff --git a/jobs/data_job_test.go b/jobs/data_job_test.go index cb67ccc143..e70055da2a 100755 --- a/jobs/data_job_test.go +++ b/jobs/data_job_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" ) @@ -215,7 +215,7 @@ func TestDataSourceQueryableJobNoMatchId(t *testing.T) { { Method: "GET", Resource: "/api/2.0/jobs/get?job_id=567", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Job 567 does not exist.", }, diff --git a/jobs/resource_job_test.go b/jobs/resource_job_test.go index 95ffb03923..98b6dc32f0 100644 --- a/jobs/resource_job_test.go +++ b/jobs/resource_job_test.go @@ -1532,7 +1532,7 @@ func TestResourceJobUpdate_ControlRunState_ContinuousUpdateRunNowFailsWith409(t JobID: 789, }, Status: 409, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "CONFLICT", Message: "A concurrent request to run the continuous job is already in progress. Please wait for it to complete before issuing a new request.", }, @@ -2127,7 +2127,7 @@ func TestResourceJobRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/jobs/get?job_id=789", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -2148,7 +2148,7 @@ func TestResourceJobRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/jobs/get?job_id=789", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/mlflow/data_mlflow_experiment_test.go b/mlflow/data_mlflow_experiment_test.go index e57bfe9c55..484d680c94 100644 --- a/mlflow/data_mlflow_experiment_test.go +++ b/mlflow/data_mlflow_experiment_test.go @@ -5,9 +5,9 @@ import ( "net/url" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/ml" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" ) @@ -50,7 +50,7 @@ func TestDataSourceExperimentByIdNotFound(t *testing.T) { Method: "GET", Resource: "/api/2.0/mlflow/experiments/get?experiment_id=0987654321", Status: 404, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Node ID 0987654321 does not exist.", }, @@ -107,7 +107,7 @@ func TestDataSourceExperimentByNameNotFound(t *testing.T) { Method: "GET", Resource: fmt.Sprintf("/api/2.0/mlflow/experiments/get-by-name?experiment_name=%s", url.QueryEscape(experimentName)), Status: 404, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Node /Users/databricks/non-existent-experiment does not exist.", }, @@ -130,7 +130,7 @@ func TestDataSourceExperimentByNameInvalidPath(t *testing.T) { Method: "GET", Resource: fmt.Sprintf("/api/2.0/mlflow/experiments/get-by-name?experiment_name=%s", url.QueryEscape(experimentName)), Status: 404, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Got an invalid experiment name 'invalid_path'. An experiment name must be an absolute path within the Databricks workspace, e.g. '/Users//my-experiment'.", }, diff --git a/mlflow/data_mlflow_model_test.go b/mlflow/data_mlflow_model_test.go index dd0b1d0bef..975595e51f 100644 --- a/mlflow/data_mlflow_model_test.go +++ b/mlflow/data_mlflow_model_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/ml" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" ) @@ -59,7 +59,7 @@ func TestDataSourceModelNotFound(t *testing.T) { Method: "GET", Resource: fmt.Sprintf("/api/2.0/mlflow/databricks/registered-models/get?name=%s", modelName), Status: 404, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: fmt.Sprintf("RegisteredModel '%s' does not exist. It might have been deleted.", modelName), }, diff --git a/mws/resource_mws_credentials_test.go b/mws/resource_mws_credentials_test.go index 6d33365974..3051f2e432 100644 --- a/mws/resource_mws_credentials_test.go +++ b/mws/resource_mws_credentials_test.go @@ -3,7 +3,7 @@ package mws import ( "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" @@ -209,7 +209,7 @@ func TestResourceCredentialsCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/accounts/abc/credentials", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -265,7 +265,7 @@ func TestResourceCredentialsRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/credentials/cid?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -286,7 +286,7 @@ func TestResourceCredentialsRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/credentials/cid?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -325,7 +325,7 @@ func TestResourceCredentialsDelete_Error(t *testing.T) { { Method: "DELETE", Resource: "/api/2.0/accounts/abc/credentials/cid?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/mws/resource_mws_customer_managed_keys_test.go b/mws/resource_mws_customer_managed_keys_test.go index 1f926dda3e..0d88239471 100644 --- a/mws/resource_mws_customer_managed_keys_test.go +++ b/mws/resource_mws_customer_managed_keys_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -75,7 +75,7 @@ func TestResourceCustomerManagedKeyCreate_Error(t *testing.T) { }, UseCases: []string{"MANAGED_SERVICE"}, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -160,7 +160,7 @@ func TestResourceCustomerManagedKeyRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/customer-managed-keys/cmkid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ Message: "Invalid endpoint", }, Status: 404, diff --git a/mws/resource_mws_log_delivery_test.go b/mws/resource_mws_log_delivery_test.go index 25e4f01b29..1374e4a994 100644 --- a/mws/resource_mws_log_delivery_test.go +++ b/mws/resource_mws_log_delivery_test.go @@ -3,7 +3,7 @@ package mws import ( "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" @@ -142,7 +142,7 @@ func TestResourceLogDeliveryCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/accounts/abc/log-delivery", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -226,7 +226,7 @@ func TestResourceLogDeliveryRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/log-delivery/nid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -307,7 +307,7 @@ func TestUpdateLogDeliveryError(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/accounts/abc/log-delivery/nid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -369,7 +369,7 @@ func TestResourceLogDeliveryDelete_Error(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/accounts/abc/log-delivery/nid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/mws/resource_mws_networks_test.go b/mws/resource_mws_networks_test.go index 0a009b7f94..0e3aa6d3ed 100644 --- a/mws/resource_mws_networks_test.go +++ b/mws/resource_mws_networks_test.go @@ -3,7 +3,7 @@ package mws import ( "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" @@ -202,7 +202,7 @@ func TestResourceNetworkCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/accounts/abc/networks", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -259,7 +259,7 @@ func TestResourceNetworkRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/networks/nid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -279,7 +279,7 @@ func TestResourceNetworkRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/networks/nid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -315,7 +315,7 @@ func TestResourceNetworkDelete(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/networks/nid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Yes, it's not found", }, @@ -336,7 +336,7 @@ func TestResourceNetworkDelete_Error(t *testing.T) { { Method: "DELETE", Resource: "/api/2.0/accounts/abc/networks/nid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/mws/resource_mws_storage_configurations_test.go b/mws/resource_mws_storage_configurations_test.go index 8154570af6..740963a4e8 100644 --- a/mws/resource_mws_storage_configurations_test.go +++ b/mws/resource_mws_storage_configurations_test.go @@ -3,7 +3,7 @@ package mws import ( "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -54,7 +54,7 @@ func TestResourceStorageConfigurationCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/accounts/abc/storage-configurations", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -106,7 +106,7 @@ func TestResourceStorageConfigurationRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/storage-configurations/scid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -126,7 +126,7 @@ func TestResourceStorageConfigurationRead_Error(t *testing.T) { { // read log output for correct url... Method: "GET", Resource: "/api/2.0/accounts/abc/storage-configurations/scid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -163,7 +163,7 @@ func TestResourceStorageConfigurationDelete_Error(t *testing.T) { { Method: "DELETE", Resource: "/api/2.0/accounts/abc/storage-configurations/scid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/mws/resource_mws_vpc_endpoint_test.go b/mws/resource_mws_vpc_endpoint_test.go index c73182f42a..ba265b1cbd 100644 --- a/mws/resource_mws_vpc_endpoint_test.go +++ b/mws/resource_mws_vpc_endpoint_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" @@ -132,7 +132,7 @@ func TestResourceVPCEndpointCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/accounts/abc/vpc-endpoints", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -185,7 +185,7 @@ func TestResourceVPCEndpointRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/vpc-endpoints/veid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -205,7 +205,7 @@ func TestResourceVPCEndpoint_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/vpc-endpoints/veid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -240,7 +240,7 @@ func TestResourceVPCEndpointDelete(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/vpc-endpoints/veid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Yes, it's not found", }, @@ -261,7 +261,7 @@ func TestResourceVPCEndpointDelete_Error(t *testing.T) { { Method: "DELETE", Resource: "/api/2.0/accounts/abc/vpc-endpoints/veid", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/mws/resource_mws_workspaces_test.go b/mws/resource_mws_workspaces_test.go index 78e49d51d0..c8a21e488a 100644 --- a/mws/resource_mws_workspaces_test.go +++ b/mws/resource_mws_workspaces_test.go @@ -199,7 +199,7 @@ func TestResourceWorkspaceCreate_Error_Custom_tags(t *testing.T) { "SoldToCode": "1234", }, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_PARAMETER_VALUE", Message: "custom_tags are only allowed for AWS workspaces", }, @@ -532,7 +532,7 @@ func TestResourceWorkspaceCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/accounts/abc/workspaces", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -541,7 +541,7 @@ func TestResourceWorkspaceCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/accounts/abc/workspaces", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -671,7 +671,7 @@ func TestResourceWorkspaceRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/workspaces/1234", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -691,7 +691,7 @@ func TestResourceWorkspaceRead_Error(t *testing.T) { { // read log output for correct url... Method: "GET", Resource: "/api/2.0/accounts/abc/workspaces/1234", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -873,7 +873,7 @@ func TestResourceWorkspaceUpdate_Error(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/accounts/abc/workspaces/1234", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -918,7 +918,7 @@ func TestResourceWorkspaceDelete(t *testing.T) { { Method: "GET", Resource: "/api/2.0/accounts/abc/workspaces/1234", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Cannot find anything", }, @@ -939,7 +939,7 @@ func TestResourceWorkspaceDelete_Error(t *testing.T) { { Method: "DELETE", Resource: "/api/2.0/accounts/abc/workspaces/1234", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/permissions/resource_access_control_rule_set_test.go b/permissions/resource_access_control_rule_set_test.go index 4225cec60c..6e4f83fdac 100644 --- a/permissions/resource_access_control_rule_set_test.go +++ b/permissions/resource_access_control_rule_set_test.go @@ -5,11 +5,11 @@ import ( "net/url" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/iam" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" ) @@ -231,7 +231,7 @@ func TestResourceRuleSetUpdateConflict(t *testing.T) { }, }, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_CONFLICT", Message: "Conflict with another RuleSet operation", }, diff --git a/permissions/resource_permissions_test.go b/permissions/resource_permissions_test.go index 80205924a6..b37807ffbe 100644 --- a/permissions/resource_permissions_test.go +++ b/permissions/resource_permissions_test.go @@ -410,7 +410,7 @@ func TestResourcePermissionsRead_NotFound(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.0/permissions/clusters/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Cluster does not exist", }, @@ -432,7 +432,7 @@ func TestResourcePermissionsRead_some_error(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.0/permissions/clusters/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -498,7 +498,7 @@ func TestResourcePermissionsRead_ErrorOnScimMe(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.0/preview/scim/v2/Me", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -652,7 +652,7 @@ func TestResourcePermissionsDelete_error(t *testing.T) { }, }, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -1003,7 +1003,7 @@ func TestResourcePermissionsCreate_NotebookPath_NotExists(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.0/workspace/get-status?path=%2FDevelopment%2FInit", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -1181,7 +1181,7 @@ func TestResourcePermissionsCreate_error(t *testing.T) { { Method: http.MethodPut, Resource: "/api/2.0/permissions/clusters/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/pipelines/resource_pipeline_test.go b/pipelines/resource_pipeline_test.go index 4fed6c1404..939e677682 100644 --- a/pipelines/resource_pipeline_test.go +++ b/pipelines/resource_pipeline_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -126,7 +126,7 @@ func TestResourcePipelineCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/pipelines", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -177,7 +177,7 @@ func TestResourcePipelineCreate_ErrorWhenWaitingFailedCleanup(t *testing.T) { { Method: "GET", Resource: "/api/2.0/pipelines/abcd", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INTERNAL_ERROR", Message: "Internal error", }, @@ -228,7 +228,7 @@ func TestResourcePipelineCreate_ErrorWhenWaitingSuccessfulCleanup(t *testing.T) { Method: "GET", Resource: "/api/2.0/pipelines/abcd", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "No such resource", }, @@ -284,7 +284,7 @@ func TestResourcePipelineRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/pipelines/abcd", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -304,7 +304,7 @@ func TestResourcePipelineRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/pipelines/abcd", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -392,7 +392,7 @@ func TestResourcePipelineUpdate_Error(t *testing.T) { { // read log output for better stub url... Method: "PUT", Resource: "/api/2.0/pipelines/abcd", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -499,7 +499,7 @@ func TestResourcePipelineDelete(t *testing.T) { { Method: "GET", Resource: "/api/2.0/pipelines/abcd", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "No such resource", }, @@ -520,7 +520,7 @@ func TestResourcePipelineDelete_Error(t *testing.T) { { Method: "DELETE", Resource: "/api/2.0/pipelines/abcd?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/policies/resource_cluster_policy_test.go b/policies/resource_cluster_policy_test.go index 30c618a26a..46980fc447 100644 --- a/policies/resource_cluster_policy_test.go +++ b/policies/resource_cluster_policy_test.go @@ -3,8 +3,8 @@ package policies import ( "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -43,7 +43,7 @@ func TestResourceClusterPolicyRead_NotFound(t *testing.T) { { // read log output for correct url... Method: "GET", Resource: "/api/2.0/policies/clusters/get?policy_id=abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -63,7 +63,7 @@ func TestResourceClusterPolicyRead_Error(t *testing.T) { { // read log output for correct url... Method: "GET", Resource: "/api/2.0/policies/clusters/get?policy_id=abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -244,7 +244,7 @@ func TestResourceClusterPolicyCreateOverrideBuiltin_ErrorListingFamilies(t *test { Method: "GET", Resource: "/api/2.0/policy-families?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -282,7 +282,7 @@ func TestResourceClusterPolicyCreateOverrideBuiltin_ErrorListingPolicies(t *test { Method: "GET", Resource: "/api/2.0/policies/clusters/list?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -322,7 +322,7 @@ func TestResourceClusterPolicyCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/policies/clusters/create", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -420,7 +420,7 @@ func TestResourceClusterPolicyUpdate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/policies/clusters/edit", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -502,7 +502,7 @@ func TestResourceClusterPolicyDeletePolicyOverride_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/policy-families?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -526,7 +526,7 @@ func TestResourceClusterPolicyDelete_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/policies/clusters/delete", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/pools/resource_instance_pool_test.go b/pools/resource_instance_pool_test.go index 501e36918e..460350e749 100644 --- a/pools/resource_instance_pool_test.go +++ b/pools/resource_instance_pool_test.go @@ -3,7 +3,7 @@ package pools import ( "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -60,7 +60,7 @@ func TestResourceInstancePoolCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/instance-pools/create", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -118,7 +118,7 @@ func TestResourceInstancePoolRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/instance-pools/get?instance_pool_id=abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -138,7 +138,7 @@ func TestResourceInstancePoolRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/instance-pools/get?instance_pool_id=abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -207,7 +207,7 @@ func TestResourceInstancePoolUpdate_Error(t *testing.T) { { // read log output for better stub url... Method: "POST", Resource: "/api/2.0/instance-pools/edit", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -255,7 +255,7 @@ func TestResourceInstancePoolDelete_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/instance-pools/delete", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/provider/generate_test.go b/provider/generate_test.go index 4bba20c1f1..c568b236a6 100644 --- a/provider/generate_test.go +++ b/provider/generate_test.go @@ -59,7 +59,7 @@ func (stub *resourceTestStub) Reads(t *testing.T) { { // read log output for correct url... Method: "GET", Resource: "/api/2.0/...", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -79,7 +79,7 @@ func (stub *resourceTestStub) Reads(t *testing.T) { { // read log output for correct url... Method: "GET", Resource: "/api/2.0/...", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -120,7 +120,7 @@ func (stub *resourceTestStub) Creates(t *testing.T) { { // read log output for better stub url... Method: "POST", Resource: "/api/2.0/...", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -165,7 +165,7 @@ func (stub *resourceTestStub) Updates(t *testing.T) { { // read log output for better stub url... Method: "POST", Resource: "/api/2.0/.../edit", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -212,7 +212,7 @@ func (stub *resourceTestStub) Deletes(t *testing.T) { { Method: "POST", Resource: "/api/2.0/.../delete", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/repos/resource_git_credential_test.go b/repos/resource_git_credential_test.go index 911a48eeb0..3f1519212e 100644 --- a/repos/resource_git_credential_test.go +++ b/repos/resource_git_credential_test.go @@ -5,8 +5,8 @@ import ( "net/http" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/workspace" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" ) @@ -41,7 +41,7 @@ func TestResourceGitCredentialRead_Error(t *testing.T) { { Method: http.MethodGet, Resource: fmt.Sprintf("/api/2.0/git-credentials/%d?", credID), - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Git credential with the given ID could not be found.", }, @@ -131,7 +131,7 @@ func TestResourceGitCredentialUpdate_Error(t *testing.T) { GitUsername: user, PersonalAccessToken: token, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Git credential with the given ID could not be found.", }, @@ -205,7 +205,7 @@ func TestResourceGitCredentialCreate_Error(t *testing.T) { GitUsername: user, PersonalAccessToken: token, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_STATE", Message: "Only one Git credential is supported at this time. If you would like to update your credential, please use the PATCH endpoint.", }, @@ -241,7 +241,7 @@ func TestResourceGitCredentialCreateWithForce(t *testing.T) { GitUsername: user, PersonalAccessToken: token, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_STATE", Message: "Only one Git credential is supported at this time. If you would like to update your credential, please use the PATCH endpoint.", }, @@ -296,7 +296,7 @@ func TestResourceGitCredentialCreateWithForce_Error_List(t *testing.T) { GitUsername: user, PersonalAccessToken: token, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_STATE", Message: "Only one Git credential is supported at this time. If you would like to update your credential, please use the PATCH endpoint.", }, @@ -305,7 +305,7 @@ func TestResourceGitCredentialCreateWithForce_Error_List(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.0/git-credentials", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "No such endpoint", }, @@ -337,7 +337,7 @@ func TestResourceGitCredentialCreateWithForce_ErrorEmptyList(t *testing.T) { GitUsername: user, PersonalAccessToken: token, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_STATE", Message: "Only one Git credential is supported at this time. If you would like to update your credential, please use the PATCH endpoint.", }, @@ -379,7 +379,7 @@ func TestResourceGitCredentialCreateWithForce_ErrorUpdate(t *testing.T) { GitUsername: user, PersonalAccessToken: token, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_STATE", Message: "Only one Git credential is supported at this time. If you would like to update your credential, please use the PATCH endpoint.", }, @@ -395,7 +395,7 @@ func TestResourceGitCredentialCreateWithForce_ErrorUpdate(t *testing.T) { { Method: http.MethodPatch, Resource: fmt.Sprintf("/api/2.0/git-credentials/%d", resp.CredentialId), - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Git credential with the given ID could not be found.", }, diff --git a/repos/resource_repo_test.go b/repos/resource_repo_test.go index 288d36e39d..0e0fc49c56 100644 --- a/repos/resource_repo_test.go +++ b/repos/resource_repo_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" ) @@ -61,7 +61,7 @@ func TestResourceRepoRead_NotFound(t *testing.T) { { Method: http.MethodGet, Resource: fmt.Sprintf("/api/2.0/repos/%s", repoID), - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Repo could not be found", }, @@ -182,7 +182,7 @@ func TestResourceRepoCreateCustomDirectoryError(t *testing.T) { ExpectedRequest: map[string]string{ "path": "/Repos/Production", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/scim/resource_entitlement_test.go b/scim/resource_entitlement_test.go index 7f5147ba52..0b73a8acf7 100644 --- a/scim/resource_entitlement_test.go +++ b/scim/resource_entitlement_test.go @@ -3,7 +3,7 @@ package scim import ( "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -178,9 +178,9 @@ func TestResourceEntitlementsGroupRead_Error(t *testing.T) { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=entitlements", Status: 400, - Response: common.APIErrorBody{ - ScimDetail: "Something", - ScimStatus: "Else", + Response: apierr.APIError{ + Message: "Something", + ErrorCode: "SCIM_Else", }, }, }, @@ -273,7 +273,7 @@ func TestResourceEntitlementsGroupDeleteEmptyEntitlement(t *testing.T) { Method: "PATCH", Resource: "/api/2.0/preview/scim/v2/Groups/abc", ExpectedRequest: deleteRequest, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_PATH", Message: "invalidPath No such attribute with the name : entitlements in the current resource", }, @@ -420,9 +420,9 @@ func TestResourceEntitlementsUserRead_Error(t *testing.T) { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Users/abc?attributes=entitlements", Status: 400, - Response: common.APIErrorBody{ - ScimDetail: "Something", - ScimStatus: "Else", + Response: apierr.APIError{ + Message: "Something", + ErrorCode: "SCIM_Else", }, }, }, @@ -441,9 +441,9 @@ func TestResourceEntitlementsUserUpdate_Error(t *testing.T) { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Users/abc?attributes=entitlements", Status: 400, - Response: common.APIErrorBody{ - ScimDetail: "Something", - ScimStatus: "Else", + Response: apierr.APIError{ + Message: "Something", + ErrorCode: "SCIM_Else", }, }, { @@ -451,9 +451,9 @@ func TestResourceEntitlementsUserUpdate_Error(t *testing.T) { Resource: "/api/2.0/preview/scim/v2/Users/abc", ExpectedRequest: updateRequest, Status: 400, - Response: common.APIErrorBody{ - ScimDetail: "Something", - ScimStatus: "Else", + Response: apierr.APIError{ + Message: "Something", + ErrorCode: "SCIM_Else", }, }, }, @@ -630,9 +630,9 @@ func TestResourceEntitlementsSPNRead_Error(t *testing.T) { Method: "GET", Resource: "/api/2.0/preview/scim/v2/ServicePrincipals/abc?attributes=entitlements", Status: 400, - Response: common.APIErrorBody{ - ScimDetail: "Something", - ScimStatus: "Else", + Response: apierr.APIError{ + Message: "Something", + ErrorCode: "SCIM_Else", }, }, }, diff --git a/scim/resource_group_member_test.go b/scim/resource_group_member_test.go index 338174ce08..24d21758c4 100644 --- a/scim/resource_group_member_test.go +++ b/scim/resource_group_member_test.go @@ -3,7 +3,7 @@ package scim import ( "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -51,7 +51,7 @@ func TestResourceGroupMemberCreate_Error(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/preview/scim/v2/Groups/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -121,7 +121,7 @@ func TestResourceGroupMemberRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=members", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -141,7 +141,7 @@ func TestResourceGroupMemberRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=members", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -181,7 +181,7 @@ func TestResourceGroupMemberDelete_Error(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/preview/scim/v2/Groups/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/scim/resource_group_role_test.go b/scim/resource_group_role_test.go index 788d0a5750..df17168aa7 100644 --- a/scim/resource_group_role_test.go +++ b/scim/resource_group_role_test.go @@ -3,7 +3,7 @@ package scim import ( "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" ) @@ -48,7 +48,7 @@ func TestResourceGroupRoleCreate_Error(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/preview/scim/v2/Groups/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -114,7 +114,7 @@ func TestResourceGroupRoleRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=roles", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -134,7 +134,7 @@ func TestResourceGroupRoleRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=roles", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -170,7 +170,7 @@ func TestResourceGroupRoleDelete_Error(t *testing.T) { { Method: "PATCH", Resource: "/api/2.0/preview/scim/v2/Groups/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/scim/resource_group_test.go b/scim/resource_group_test.go index 0b8a496514..f45fa83ec7 100644 --- a/scim/resource_group_test.go +++ b/scim/resource_group_test.go @@ -82,7 +82,7 @@ func TestResourceGroupCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/preview/scim/v2/Groups", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -164,7 +164,7 @@ func TestResourceGroupRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=displayName,externalId,entitlements", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -184,7 +184,7 @@ func TestResourceGroupRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=displayName,externalId,entitlements", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -300,7 +300,7 @@ func TestResourceGroupUpdate_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Groups/abc?attributes=displayName,entitlements,groups,members,externalId", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -338,7 +338,7 @@ func TestResourceGroupDelete_Error(t *testing.T) { { Method: "DELETE", Resource: "/api/2.0/preview/scim/v2/Groups/abc", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/scim/resource_service_principal.go b/scim/resource_service_principal.go index f867d67220..befcf8c632 100644 --- a/scim/resource_service_principal.go +++ b/scim/resource_service_principal.go @@ -226,7 +226,7 @@ func ResourceServicePrincipal() common.Resource { return err } // Handle force delete flags - if !isAccount && !isDisable && err == nil { + if !isAccount && !isDisable { if isForceDeleteRepos { err = workspace.NewNotebooksAPI(ctx, c).Delete(fmt.Sprintf("/Repos/%v", appId), true) if err != nil && !apierr.IsMissing(err) { diff --git a/scim/resource_service_principal_test.go b/scim/resource_service_principal_test.go index f27c05cf75..dcd27b23c7 100644 --- a/scim/resource_service_principal_test.go +++ b/scim/resource_service_principal_test.go @@ -73,9 +73,9 @@ func TestResourceServicePrincipalRead_Error(t *testing.T) { Method: "GET", Resource: "/api/2.0/preview/scim/v2/ServicePrincipals/abc?attributes=userName,displayName,active,externalId,entitlements", Status: 400, - Response: common.APIErrorBody{ - ScimDetail: "Something", - ScimStatus: "Else", + Response: apierr.APIError{ + Message: "Something", + ErrorCode: "SCIM_Else", }, }, }, @@ -474,7 +474,7 @@ func TestResourceServicePrincipalDelete_NonExistingRepo(t *testing.T) { Path: "/Repos/abc", Recursive: true, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Path (/Repos/abc) doesn't exist.", }, @@ -533,7 +533,7 @@ func TestResourceServicePrincipalDelete_NonExistingDir(t *testing.T) { Path: "/Users/abc", Recursive: true, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Path (/Users/abc) doesn't exist.", }, diff --git a/scim/resource_user.go b/scim/resource_user.go index a5a412c41b..80b53f42bf 100644 --- a/scim/resource_user.go +++ b/scim/resource_user.go @@ -150,7 +150,7 @@ func ResourceUser() common.Resource { return err } // Handle force delete flags - if !isAccount && !isDisable && err == nil { + if !isAccount && !isDisable { if isForceDeleteRepos { err = workspace.NewNotebooksAPI(ctx, c).Delete(fmt.Sprintf("/Repos/%v", userName), true) if err != nil && !apierr.IsMissing(err) { diff --git a/scim/resource_user_test.go b/scim/resource_user_test.go index fa0d61220d..dcb65ef657 100644 --- a/scim/resource_user_test.go +++ b/scim/resource_user_test.go @@ -5,6 +5,7 @@ import ( "fmt" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/workspace" @@ -75,9 +76,9 @@ func TestResourceUserRead_Error(t *testing.T) { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Users/abc?attributes=userName,displayName,active,externalId,entitlements", Status: 400, - Response: common.APIErrorBody{ - ScimDetail: "Something", - ScimStatus: "Else", + Response: apierr.APIError{ + Message: "Something", + ErrorCode: "SCIM_Else", }, }, }, @@ -514,7 +515,7 @@ func TestResourceUserDelete_NonExistingRepo(t *testing.T) { Path: "/Repos/abc", Recursive: true, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Path (/Repos/abc) doesn't exist.", }, @@ -572,7 +573,7 @@ func TestResourceUserDelete_NonExistingDir(t *testing.T) { Path: "/Users/abc", Recursive: true, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Path (/Users/abc) doesn't exist.", }, @@ -631,7 +632,7 @@ func TestCreateForceOverwriteCannotListUsers(t *testing.T) { Method: "GET", Resource: "/api/2.0/preview/scim/v2/Users?excludedAttributes=roles&filter=userName%20eq%20%22me%40example.com%22", Status: 417, - Response: common.APIErrorBody{ + Response: apierr.APIError{ Message: "cannot find user", }, }, diff --git a/secrets/resource_secret_acl_test.go b/secrets/resource_secret_acl_test.go index e70475890c..dfd1a5e875 100644 --- a/secrets/resource_secret_acl_test.go +++ b/secrets/resource_secret_acl_test.go @@ -3,8 +3,8 @@ package secrets import ( "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/workspace" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -37,7 +37,7 @@ func TestResourceSecretACLRead_NotFound(t *testing.T) { { Method: "GET", Resource: "/api/2.0/secrets/acls/get?principal=something&scope=global", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -57,7 +57,7 @@ func TestResourceSecretACLRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/secrets/acls/get?principal=something&scope=global", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -142,7 +142,7 @@ func TestResourceSecretACLCreate_Error(t *testing.T) { { // read log output for better stub url... Method: "POST", Resource: "/api/2.0/secrets/acls/put", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -187,7 +187,7 @@ func TestResourceSecretACLDelete_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/secrets/acls/delete", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/secrets/resource_secret_scope_test.go b/secrets/resource_secret_scope_test.go index 455aac6d77..c29f702b8d 100644 --- a/secrets/resource_secret_scope_test.go +++ b/secrets/resource_secret_scope_test.go @@ -4,8 +4,8 @@ import ( "net/http" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/workspace" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -104,7 +104,7 @@ func TestResourceSecretScopeRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/secrets/scopes/list", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -244,7 +244,7 @@ func TestResourceSecretScopeCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/secrets/scopes/create", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -287,7 +287,7 @@ func TestResourceSecretScopeDelete_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/secrets/scopes/delete", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/secrets/resource_secret_test.go b/secrets/resource_secret_test.go index 3ab58b7722..a0d08a5db7 100644 --- a/secrets/resource_secret_test.go +++ b/secrets/resource_secret_test.go @@ -3,8 +3,8 @@ package secrets import ( "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/workspace" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -67,7 +67,7 @@ func TestResourceSecretRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/secrets/list?scope=foo", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -125,7 +125,7 @@ func TestResourceSecretCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/secrets/put", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -170,7 +170,7 @@ func TestResourceSecretDelete_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/secrets/delete", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/serving/resource_model_serving_test.go b/serving/resource_model_serving_test.go index c53d17c49f..2175c88b0a 100644 --- a/serving/resource_model_serving_test.go +++ b/serving/resource_model_serving_test.go @@ -4,8 +4,8 @@ import ( "net/http" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/serving" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" ) @@ -277,7 +277,7 @@ func TestModelServingCreate_Error(t *testing.T) { { Method: http.MethodPost, Resource: "/api/2.0/serving-endpoints", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -335,7 +335,7 @@ func TestModelServingCreate_WithErrorOnWait(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.0/serving-endpoints/test-endpoint?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -449,7 +449,7 @@ func TestModelServingRead_Error(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.0/serving-endpoints/test-endpoint?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -565,7 +565,7 @@ func TestModelServingUpdate_Error(t *testing.T) { { Method: http.MethodPut, Resource: "/api/2.0/serving-endpoints/test-endpoint/config", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -620,7 +620,7 @@ func TestModelServingDelete_Error(t *testing.T) { { Method: http.MethodDelete, Resource: "/api/2.0/serving-endpoints/test-endpoint?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/sharing/resource_recipient_test.go b/sharing/resource_recipient_test.go index 40cb8ffd68..9ca03bdf5f 100644 --- a/sharing/resource_recipient_test.go +++ b/sharing/resource_recipient_test.go @@ -4,8 +4,8 @@ import ( "net/http" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/sharing" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -329,7 +329,7 @@ func TestUpdateRecipientRollback(t *testing.T) { ExpectedRequest: sharing.UpdateRecipient{ Comment: "e", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -402,7 +402,7 @@ func TestDeleteRecipientError(t *testing.T) { { Method: http.MethodDelete, Resource: "/api/2.1/unity-catalog/recipients/testRecipient?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_STATE", Message: "Something went wrong", }, diff --git a/sharing/resource_share_test.go b/sharing/resource_share_test.go index 7d03f76089..bcda081393 100644 --- a/sharing/resource_share_test.go +++ b/sharing/resource_share_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/assert" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/sharing" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" ) @@ -426,7 +426,7 @@ func TestUpdateShareRollback(t *testing.T) { }, }, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "SERVER_ERROR", Message: "Something unexpected happened", }, @@ -557,7 +557,7 @@ func TestCreateShare_ThrowError(t *testing.T) { ExpectedRequest: ShareInfo{ Name: "a", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -620,7 +620,7 @@ func TestCreateShareButPatchFails(t *testing.T) { }, }, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/storage/resource_file_test.go b/storage/resource_file_test.go index dea290c509..c925069060 100644 --- a/storage/resource_file_test.go +++ b/storage/resource_file_test.go @@ -4,8 +4,8 @@ import ( "net/http" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/files" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -94,7 +94,7 @@ func TestResourceFileCreate_Error(t *testing.T) { { Method: http.MethodPut, Resource: "/api/2.0/fs/files/Volumes/CatalogName/SchemaName/VolumeName/fileName", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -185,7 +185,7 @@ func TestResourceFileDelete_Error(t *testing.T) { { Method: "DELETE", Resource: "/api/2.0/fs/files/Volumes/CatalogName/SchemaName/VolumeName/fileName?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/tokens/resource_token_test.go b/tokens/resource_token_test.go index 81fb542ddf..2352b62a0e 100644 --- a/tokens/resource_token_test.go +++ b/tokens/resource_token_test.go @@ -5,7 +5,6 @@ import ( "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -72,7 +71,7 @@ func TestResourceTokenRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/token/list", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -138,7 +137,7 @@ func TestResourceTokenCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/token/create", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -239,7 +238,7 @@ func TestResourceTokenDelete_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/token/delete", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/workspace/resource_directory_test.go b/workspace/resource_directory_test.go index d11c73d4dc..bfce13713c 100644 --- a/workspace/resource_directory_test.go +++ b/workspace/resource_directory_test.go @@ -6,7 +6,7 @@ import ( "net/url" "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" @@ -70,7 +70,7 @@ func TestResourceDirectoryDelete_NotFound(t *testing.T) { Method: http.MethodPost, Resource: "/api/2.0/workspace/delete", ExpectedRequest: DeletePath{Path: path, Recursive: delete_recursive}, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "Path (/test/path) doesn't exist.", }, @@ -96,7 +96,7 @@ func TestResourceDirectoryRead_NotFound(t *testing.T) { { // read log output for correct url... Method: "GET", Resource: fmt.Sprintf("/api/2.0/workspace/get-status?path=%s", url.PathEscape(path)), - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -117,7 +117,7 @@ func TestResourceDirectoryRead_Error(t *testing.T) { { Method: "GET", Resource: fmt.Sprintf("/api/2.0/workspace/get-status?path=%s", url.PathEscape(path)), - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -175,7 +175,7 @@ func TestResourceDirectoryCreate_Error(t *testing.T) { ExpectedRequest: map[string]string{ "path": path, }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -200,7 +200,7 @@ func TestResourceDirectoryDelete_Error(t *testing.T) { Method: "POST", Resource: "/api/2.0/workspace/delete", ExpectedRequest: DeletePath{Path: path, Recursive: false}, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/workspace/resource_global_init_script_test.go b/workspace/resource_global_init_script_test.go index a29a4bf497..210df745b2 100644 --- a/workspace/resource_global_init_script_test.go +++ b/workspace/resource_global_init_script_test.go @@ -6,8 +6,8 @@ import ( "strings" "testing" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" @@ -70,7 +70,7 @@ func TestResourceGlobalInitScriptRead_NotFound(t *testing.T) { { // read log output for correct url... Method: "GET", Resource: "/api/2.0/global-init-scripts/1234?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "RESOURCE_DOES_NOT_EXIST", Message: "The global unit script with ID 1234 does not exist.", }, diff --git a/workspace/resource_notebook_test.go b/workspace/resource_notebook_test.go index 938b119ead..6547f7894b 100644 --- a/workspace/resource_notebook_test.go +++ b/workspace/resource_notebook_test.go @@ -4,7 +4,7 @@ import ( "net/http" "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" @@ -63,7 +63,7 @@ func TestResourceNotebookRead_NotFound(t *testing.T) { { // read log output for correct url... Method: "GET", Resource: "/api/2.0/workspace/get-status?path=%2Ftest%2Fpath", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -83,7 +83,7 @@ func TestResourceNotebookRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/workspace/get-status?path=%2Ftest%2Fpath", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -225,7 +225,7 @@ func TestResourceNotebookCreate_DirectoryCreateError(t *testing.T) { ExpectedRequest: map[string]string{ "path": "/foo", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -357,7 +357,7 @@ func TestResourceNotebookCreate_Error(t *testing.T) { { Method: http.MethodPost, Resource: "/api/2.0/workspace/import", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -382,7 +382,7 @@ func TestResourceNotebookDelete_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/workspace/delete", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, diff --git a/workspace/resource_workspace_conf_test.go b/workspace/resource_workspace_conf_test.go index b8a87ce877..29e76771b5 100644 --- a/workspace/resource_workspace_conf_test.go +++ b/workspace/resource_workspace_conf_test.go @@ -4,7 +4,7 @@ import ( "net/http" "testing" - "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" ) @@ -47,7 +47,7 @@ func TestWorkspaceConfCreate_Error(t *testing.T) { ExpectedRequest: map[string]string{ "enableIpAccessLists": "true", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -120,7 +120,7 @@ func TestWorkspaceConfUpdate_Error(t *testing.T) { ExpectedRequest: map[string]string{ "enableIpAccessLists": "true", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -159,7 +159,7 @@ func TestWorkspaceConfRead_Error(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.0/workspace-conf?", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -208,7 +208,7 @@ func TestWorkspaceConfDelete_Error(t *testing.T) { { Method: http.MethodPatch, Resource: "/api/2.0/workspace-conf", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -230,7 +230,7 @@ func TestWorkspaceConfUpdateOnInvalidConf(t *testing.T) { Method: http.MethodPatch, Resource: "/api/2.0/workspace-conf", Status: 400, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "some-invalid-conf is an invalid config key", }, diff --git a/workspace/resource_workspace_file_test.go b/workspace/resource_workspace_file_test.go index 92518f00cf..0241f573c6 100644 --- a/workspace/resource_workspace_file_test.go +++ b/workspace/resource_workspace_file_test.go @@ -4,8 +4,8 @@ import ( "net/http" "testing" + "github.com/databricks/databricks-sdk-go/apierr" ws_api "github.com/databricks/databricks-sdk-go/service/workspace" - "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" "github.com/stretchr/testify/assert" @@ -68,7 +68,7 @@ func TestResourceWorkspaceFileRead_NotFound(t *testing.T) { { // read log output for correct url... Method: "GET", Resource: "/api/2.0/workspace/get-status?path=%2Ftest%2Fpath", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "NOT_FOUND", Message: "Item not found", }, @@ -88,7 +88,7 @@ func TestResourceWorkspaceFileRead_Error(t *testing.T) { { Method: "GET", Resource: "/api/2.0/workspace/get-status?path=%2Ftest%2Fpath", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -223,7 +223,7 @@ func TestResourceWorkspaceFileCreate_DirectoryCreateError(t *testing.T) { ExpectedRequest: map[string]string{ "path": "/foo", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -338,7 +338,7 @@ func TestResourceWorkspaceFileCreate_Error(t *testing.T) { "overwrite": true, "path": "/path.py", }, - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", }, @@ -362,7 +362,7 @@ func TestResourceWorkspaceFileDelete_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/workspace/delete", - Response: common.APIErrorBody{ + Response: apierr.APIError{ ErrorCode: "INVALID_REQUEST", Message: "Internal error happened", },