diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..222e2cc --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,12 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${fileDirname}" + } + ] +} diff --git a/fabric/admin/domains_client.go b/fabric/admin/domains_client.go index 78f5c0c..d1a0a5a 100644 --- a/fabric/admin/domains_client.go +++ b/fabric/admin/domains_client.go @@ -851,7 +851,15 @@ func (client *DomainsClient) updateDomainHandleResponse(resp *http.Response) (Do // - assignDomainWorkspacesByCapacitiesRequest - The request payload for assigning workspaces to the domain by capacity. // - options - DomainsClientBeginAssignDomainWorkspacesByCapacitiesOptions contains the optional parameters for the DomainsClient.BeginAssignDomainWorkspacesByCapacities method. func (client *DomainsClient) AssignDomainWorkspacesByCapacities(ctx context.Context, domainID string, assignDomainWorkspacesByCapacitiesRequest AssignDomainWorkspacesByCapacitiesRequest, options *DomainsClientBeginAssignDomainWorkspacesByCapacitiesOptions) (DomainsClientAssignDomainWorkspacesByCapacitiesResponse, error) { - return iruntime.NewLRO(client.BeginAssignDomainWorkspacesByCapacities(ctx, domainID, assignDomainWorkspacesByCapacitiesRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginAssignDomainWorkspacesByCapacities(ctx, domainID, assignDomainWorkspacesByCapacitiesRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return DomainsClientAssignDomainWorkspacesByCapacitiesResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return DomainsClientAssignDomainWorkspacesByCapacitiesResponse{}, err + } + return result, err } // beginAssignDomainWorkspacesByCapacities creates the assignDomainWorkspacesByCapacities request. @@ -917,7 +925,15 @@ func (client *DomainsClient) beginAssignDomainWorkspacesByCapacities(ctx context // - assignDomainWorkspacesByPrincipalsRequest - The request payload for assigning workspaces to the domain by principal. // - options - DomainsClientBeginAssignDomainWorkspacesByPrincipalsOptions contains the optional parameters for the DomainsClient.BeginAssignDomainWorkspacesByPrincipals method. func (client *DomainsClient) AssignDomainWorkspacesByPrincipals(ctx context.Context, domainID string, assignDomainWorkspacesByPrincipalsRequest AssignDomainWorkspacesByPrincipalsRequest, options *DomainsClientBeginAssignDomainWorkspacesByPrincipalsOptions) (DomainsClientAssignDomainWorkspacesByPrincipalsResponse, error) { - return iruntime.NewLRO(client.BeginAssignDomainWorkspacesByPrincipals(ctx, domainID, assignDomainWorkspacesByPrincipalsRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginAssignDomainWorkspacesByPrincipals(ctx, domainID, assignDomainWorkspacesByPrincipalsRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return DomainsClientAssignDomainWorkspacesByPrincipalsResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return DomainsClientAssignDomainWorkspacesByPrincipalsResponse{}, err + } + return result, err } // beginAssignDomainWorkspacesByPrincipals creates the assignDomainWorkspacesByPrincipals request. @@ -985,7 +1001,11 @@ func (client *DomainsClient) ListDomainWorkspaces(ctx context.Context, domainID } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []DomainWorkspace{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []DomainWorkspace{}, err } return list, nil } diff --git a/fabric/admin/externaldatashares_client.go b/fabric/admin/externaldatashares_client.go index 189a9e7..3593080 100644 --- a/fabric/admin/externaldatashares_client.go +++ b/fabric/admin/externaldatashares_client.go @@ -186,7 +186,11 @@ func (client *ExternalDataSharesClient) ListExternalDataShares(ctx context.Conte } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []ExternalDataShare{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []ExternalDataShare{}, err } return list, nil } diff --git a/fabric/admin/items_client.go b/fabric/admin/items_client.go index 3643d81..8211674 100644 --- a/fabric/admin/items_client.go +++ b/fabric/admin/items_client.go @@ -292,7 +292,11 @@ func (client *ItemsClient) ListItems(ctx context.Context, options *ItemsClientLi } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Item{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []Item{}, err } return list, nil } diff --git a/fabric/admin/tenants_client.go b/fabric/admin/tenants_client.go index 7c693ab..20a873e 100644 --- a/fabric/admin/tenants_client.go +++ b/fabric/admin/tenants_client.go @@ -8,6 +8,7 @@ package admin import ( "context" + "errors" "net/http" "github.com/Azure/azure-sdk-for-go/sdk/azcore" @@ -175,7 +176,11 @@ func (client *TenantsClient) ListCapacitiesTenantSettingsOverrides(ctx context.C } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []TenantSettingOverride{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []TenantSettingOverride{}, err } return list, nil } diff --git a/fabric/admin/users_client.go b/fabric/admin/users_client.go index 335b1b1..63a6e90 100644 --- a/fabric/admin/users_client.go +++ b/fabric/admin/users_client.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/microsoft/fabric-sdk-go/fabric/core" "github.com/microsoft/fabric-sdk-go/internal/iruntime" ) @@ -146,7 +147,11 @@ func (client *UsersClient) ListAccessEntities(ctx context.Context, userID string } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []AccessEntity{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []AccessEntity{}, err } return list, nil } diff --git a/fabric/admin/workspaces_client.go b/fabric/admin/workspaces_client.go index 16140df..d37aac0 100644 --- a/fabric/admin/workspaces_client.go +++ b/fabric/admin/workspaces_client.go @@ -255,7 +255,11 @@ func (client *WorkspacesClient) ListWorkspaces(ctx context.Context, options *Wor } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Workspace{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []Workspace{}, err } return list, nil } diff --git a/fabric/core/capacities_client.go b/fabric/core/capacities_client.go index fb3836f..b0f7a91 100644 --- a/fabric/core/capacities_client.go +++ b/fabric/core/capacities_client.go @@ -8,6 +8,7 @@ package core import ( "context" + "errors" "net/http" "github.com/Azure/azure-sdk-for-go/sdk/azcore" @@ -106,7 +107,11 @@ func (client *CapacitiesClient) ListCapacities(ctx context.Context, options *Cap } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Capacity{}, NewResponseError(azcoreRespError.RawResponse) + } + return []Capacity{}, err } return list, nil } diff --git a/fabric/core/deploymentpipelines_client.go b/fabric/core/deploymentpipelines_client.go index a5225f0..114ce1c 100644 --- a/fabric/core/deploymentpipelines_client.go +++ b/fabric/core/deploymentpipelines_client.go @@ -390,7 +390,15 @@ func (client *DeploymentPipelinesClient) listDeploymentPipelinesHandleResponse(r // - deployRequest - The deploy request. // - options - DeploymentPipelinesClientBeginDeployStageContentOptions contains the optional parameters for the DeploymentPipelinesClient.BeginDeployStageContent method. func (client *DeploymentPipelinesClient) DeployStageContent(ctx context.Context, deploymentPipelineID string, deployRequest DeployRequest, options *DeploymentPipelinesClientBeginDeployStageContentOptions) (DeploymentPipelinesClientDeployStageContentResponse, error) { - return iruntime.NewLRO(client.BeginDeployStageContent(ctx, deploymentPipelineID, deployRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginDeployStageContent(ctx, deploymentPipelineID, deployRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return DeploymentPipelinesClientDeployStageContentResponse{}, NewResponseError(azcoreRespError.RawResponse) + } + return DeploymentPipelinesClientDeployStageContentResponse{}, err + } + return result, err } // beginDeployStageContent creates the deployStageContent request. @@ -457,7 +465,11 @@ func (client *DeploymentPipelinesClient) ListDeploymentPipelineStageItems(ctx co } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []DeploymentPipelineStageItem{}, NewResponseError(azcoreRespError.RawResponse) + } + return []DeploymentPipelineStageItem{}, err } return list, nil } @@ -481,7 +493,11 @@ func (client *DeploymentPipelinesClient) ListDeploymentPipelineStages(ctx contex } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []DeploymentPipelineStage{}, NewResponseError(azcoreRespError.RawResponse) + } + return []DeploymentPipelineStage{}, err } return list, nil } @@ -504,7 +520,11 @@ func (client *DeploymentPipelinesClient) ListDeploymentPipelines(ctx context.Con } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []DeploymentPipeline{}, NewResponseError(azcoreRespError.RawResponse) + } + return []DeploymentPipeline{}, err } return list, nil } diff --git a/fabric/core/errors.go b/fabric/core/errors.go index 959c306..9c5f287 100644 --- a/fabric/core/errors.go +++ b/fabric/core/errors.go @@ -33,6 +33,32 @@ func NewResponseError(resp *http.Response) error { return err } + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(respBody, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling error: %v", err) + } + + // handle LRO result error + if rawMsg["error"] != nil && rawMsg["status"] != nil { + var errorMap map[string]any + if err := json.Unmarshal(rawMsg["error"], &errorMap); err != nil { + return fmt.Errorf("unmarshalling error field: %v", err) + } + + errorMap["requestId"] = resp.Header.Get("requestId") + errorMap["moreDetails"] = []map[string]any{ + { + "errorCode": string(rawMsg["status"]), + "message": "Long Running Operation: " + string(rawMsg["status"]), + }, + } + + respBody, err = json.Marshal(errorMap) + if err != nil { + return fmt.Errorf("marshalling error field: %v", err) + } + } + var errResp ErrorResponse if err := errResp.UnmarshalJSON(respBody); err != nil { return err diff --git a/fabric/core/externaldatashares_client.go b/fabric/core/externaldatashares_client.go index 11aba92..f66966d 100644 --- a/fabric/core/externaldatashares_client.go +++ b/fabric/core/externaldatashares_client.go @@ -372,7 +372,11 @@ func (client *ExternalDataSharesClient) ListExternalDataSharesInItem(ctx context } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []ExternalDataShare{}, NewResponseError(azcoreRespError.RawResponse) + } + return []ExternalDataShare{}, err } return list, nil } diff --git a/fabric/core/git_client.go b/fabric/core/git_client.go index 8e10aa9..253f0ce 100644 --- a/fabric/core/git_client.go +++ b/fabric/core/git_client.go @@ -522,7 +522,15 @@ func (client *GitClient) updateFromGitCreateRequest(ctx context.Context, workspa // - commitToGitRequest - Commit to the Git request payload. // - options - GitClientBeginCommitToGitOptions contains the optional parameters for the GitClient.BeginCommitToGit method. func (client *GitClient) CommitToGit(ctx context.Context, workspaceID string, commitToGitRequest CommitToGitRequest, options *GitClientBeginCommitToGitOptions) (GitClientCommitToGitResponse, error) { - return iruntime.NewLRO(client.BeginCommitToGit(ctx, workspaceID, commitToGitRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCommitToGit(ctx, workspaceID, commitToGitRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return GitClientCommitToGitResponse{}, NewResponseError(azcoreRespError.RawResponse) + } + return GitClientCommitToGitResponse{}, err + } + return result, err } // beginCommitToGit creates the commitToGit request. @@ -585,7 +593,15 @@ func (client *GitClient) beginCommitToGit(ctx context.Context, workspaceID strin // - workspaceID - The workspace ID. // - options - GitClientBeginGetStatusOptions contains the optional parameters for the GitClient.BeginGetStatus method. func (client *GitClient) GetStatus(ctx context.Context, workspaceID string, options *GitClientBeginGetStatusOptions) (GitClientGetStatusResponse, error) { - return iruntime.NewLRO(client.BeginGetStatus(ctx, workspaceID, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginGetStatus(ctx, workspaceID, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return GitClientGetStatusResponse{}, NewResponseError(azcoreRespError.RawResponse) + } + return GitClientGetStatusResponse{}, err + } + return result, err } // beginGetStatus creates the getStatus request. @@ -650,7 +666,15 @@ func (client *GitClient) beginGetStatus(ctx context.Context, workspaceID string, // - workspaceID - The workspace ID. // - options - GitClientBeginInitializeConnectionOptions contains the optional parameters for the GitClient.BeginInitializeConnection method. func (client *GitClient) InitializeConnection(ctx context.Context, workspaceID string, options *GitClientBeginInitializeConnectionOptions) (GitClientInitializeConnectionResponse, error) { - return iruntime.NewLRO(client.BeginInitializeConnection(ctx, workspaceID, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginInitializeConnection(ctx, workspaceID, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return GitClientInitializeConnectionResponse{}, NewResponseError(azcoreRespError.RawResponse) + } + return GitClientInitializeConnectionResponse{}, err + } + return result, err } // beginInitializeConnection creates the initializeConnection request. @@ -715,7 +739,15 @@ func (client *GitClient) beginInitializeConnection(ctx context.Context, workspac // - updateFromGitRequest - Update from a Git request payload. // - options - GitClientBeginUpdateFromGitOptions contains the optional parameters for the GitClient.BeginUpdateFromGit method. func (client *GitClient) UpdateFromGit(ctx context.Context, workspaceID string, updateFromGitRequest UpdateFromGitRequest, options *GitClientBeginUpdateFromGitOptions) (GitClientUpdateFromGitResponse, error) { - return iruntime.NewLRO(client.BeginUpdateFromGit(ctx, workspaceID, updateFromGitRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginUpdateFromGit(ctx, workspaceID, updateFromGitRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return GitClientUpdateFromGitResponse{}, NewResponseError(azcoreRespError.RawResponse) + } + return GitClientUpdateFromGitResponse{}, err + } + return result, err } // beginUpdateFromGit creates the updateFromGit request. diff --git a/fabric/core/items_client.go b/fabric/core/items_client.go index 7e67412..e95dc3e 100644 --- a/fabric/core/items_client.go +++ b/fabric/core/items_client.go @@ -762,7 +762,15 @@ func (client *ItemsClient) updateItemDefinitionCreateRequest(ctx context.Context // - createItemRequest - Create item request payload. // - options - ItemsClientBeginCreateItemOptions contains the optional parameters for the ItemsClient.BeginCreateItem method. func (client *ItemsClient) CreateItem(ctx context.Context, workspaceID string, createItemRequest CreateItemRequest, options *ItemsClientBeginCreateItemOptions) (ItemsClientCreateItemResponse, error) { - return iruntime.NewLRO(client.BeginCreateItem(ctx, workspaceID, createItemRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateItem(ctx, workspaceID, createItemRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateItemResponse{}, NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateItemResponse{}, err + } + return result, err } // beginCreateItem creates the createItem request. @@ -837,7 +845,15 @@ func (client *ItemsClient) beginCreateItem(ctx context.Context, workspaceID stri // - itemID - The item ID. // - options - ItemsClientBeginGetItemDefinitionOptions contains the optional parameters for the ItemsClient.BeginGetItemDefinition method. func (client *ItemsClient) GetItemDefinition(ctx context.Context, workspaceID string, itemID string, options *ItemsClientBeginGetItemDefinitionOptions) (ItemsClientGetItemDefinitionResponse, error) { - return iruntime.NewLRO(client.BeginGetItemDefinition(ctx, workspaceID, itemID, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginGetItemDefinition(ctx, workspaceID, itemID, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientGetItemDefinitionResponse{}, NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientGetItemDefinitionResponse{}, err + } + return result, err } // beginGetItemDefinition creates the getItemDefinition request. @@ -911,7 +927,15 @@ func (client *ItemsClient) beginGetItemDefinition(ctx context.Context, workspace // - updateItemDefinitionRequest - Update item definition request payload. // - options - ItemsClientBeginUpdateItemDefinitionOptions contains the optional parameters for the ItemsClient.BeginUpdateItemDefinition method. func (client *ItemsClient) UpdateItemDefinition(ctx context.Context, workspaceID string, itemID string, updateItemDefinitionRequest UpdateItemDefinitionRequest, options *ItemsClientBeginUpdateItemDefinitionOptions) (ItemsClientUpdateItemDefinitionResponse, error) { - return iruntime.NewLRO(client.BeginUpdateItemDefinition(ctx, workspaceID, itemID, updateItemDefinitionRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginUpdateItemDefinition(ctx, workspaceID, itemID, updateItemDefinitionRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientUpdateItemDefinitionResponse{}, NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientUpdateItemDefinitionResponse{}, err + } + return result, err } // beginUpdateItemDefinition creates the updateItemDefinition request. @@ -986,7 +1010,11 @@ func (client *ItemsClient) ListItemConnections(ctx context.Context, workspaceID } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []ItemConnection{}, NewResponseError(azcoreRespError.RawResponse) + } + return []ItemConnection{}, err } return list, nil } @@ -1014,7 +1042,11 @@ func (client *ItemsClient) ListItems(ctx context.Context, workspaceID string, op } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Item{}, NewResponseError(azcoreRespError.RawResponse) + } + return []Item{}, err } return list, nil } diff --git a/fabric/core/onelakeshortcuts_client.go b/fabric/core/onelakeshortcuts_client.go index 2bba28e..113f465 100644 --- a/fabric/core/onelakeshortcuts_client.go +++ b/fabric/core/onelakeshortcuts_client.go @@ -340,7 +340,11 @@ func (client *OneLakeShortcutsClient) ListShortcuts(ctx context.Context, workspa } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Shortcut{}, NewResponseError(azcoreRespError.RawResponse) + } + return []Shortcut{}, err } return list, nil } diff --git a/fabric/core/workspaces_client.go b/fabric/core/workspaces_client.go index 26c7d96..97af284 100644 --- a/fabric/core/workspaces_client.go +++ b/fabric/core/workspaces_client.go @@ -932,7 +932,15 @@ func (client *WorkspacesClient) updateWorkspaceRoleAssignmentHandleResponse(resp // - workspaceID - The ID of the workspace. // - options - WorkspacesClientBeginDeprovisionIdentityOptions contains the optional parameters for the WorkspacesClient.BeginDeprovisionIdentity method. func (client *WorkspacesClient) DeprovisionIdentity(ctx context.Context, workspaceID string, options *WorkspacesClientBeginDeprovisionIdentityOptions) (WorkspacesClientDeprovisionIdentityResponse, error) { - return iruntime.NewLRO(client.BeginDeprovisionIdentity(ctx, workspaceID, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginDeprovisionIdentity(ctx, workspaceID, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return WorkspacesClientDeprovisionIdentityResponse{}, NewResponseError(azcoreRespError.RawResponse) + } + return WorkspacesClientDeprovisionIdentityResponse{}, err + } + return result, err } // beginDeprovisionIdentity creates the deprovisionIdentity request. @@ -994,7 +1002,15 @@ func (client *WorkspacesClient) beginDeprovisionIdentity(ctx context.Context, wo // - workspaceID - The ID of the workspace. // - options - WorkspacesClientBeginProvisionIdentityOptions contains the optional parameters for the WorkspacesClient.BeginProvisionIdentity method. func (client *WorkspacesClient) ProvisionIdentity(ctx context.Context, workspaceID string, options *WorkspacesClientBeginProvisionIdentityOptions) (WorkspacesClientProvisionIdentityResponse, error) { - return iruntime.NewLRO(client.BeginProvisionIdentity(ctx, workspaceID, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginProvisionIdentity(ctx, workspaceID, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return WorkspacesClientProvisionIdentityResponse{}, NewResponseError(azcoreRespError.RawResponse) + } + return WorkspacesClientProvisionIdentityResponse{}, err + } + return result, err } // beginProvisionIdentity creates the provisionIdentity request. @@ -1060,7 +1076,11 @@ func (client *WorkspacesClient) ListWorkspaceRoleAssignments(ctx context.Context } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []WorkspaceRoleAssignment{}, NewResponseError(azcoreRespError.RawResponse) + } + return []WorkspaceRoleAssignment{}, err } return list, nil } @@ -1085,7 +1105,11 @@ func (client *WorkspacesClient) ListWorkspaces(ctx context.Context, options *Wor } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Workspace{}, NewResponseError(azcoreRespError.RawResponse) + } + return []Workspace{}, err } return list, nil } diff --git a/fabric/dashboard/items_client.go b/fabric/dashboard/items_client.go index 3236a52..e97f233 100644 --- a/fabric/dashboard/items_client.go +++ b/fabric/dashboard/items_client.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/microsoft/fabric-sdk-go/fabric/core" "github.com/microsoft/fabric-sdk-go/internal/iruntime" ) @@ -118,7 +119,11 @@ func (client *ItemsClient) ListDashboards(ctx context.Context, workspaceID strin } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Dashboard{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []Dashboard{}, err } return list, nil } diff --git a/fabric/datamart/items_client.go b/fabric/datamart/items_client.go index e96dfdc..8ff88c1 100644 --- a/fabric/datamart/items_client.go +++ b/fabric/datamart/items_client.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/microsoft/fabric-sdk-go/fabric/core" "github.com/microsoft/fabric-sdk-go/internal/iruntime" ) @@ -117,7 +118,11 @@ func (client *ItemsClient) ListDatamarts(ctx context.Context, workspaceID string } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Datamart{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []Datamart{}, err } return list, nil } diff --git a/fabric/datapipeline/items_client.go b/fabric/datapipeline/items_client.go index e777f64..d4a1d10 100644 --- a/fabric/datapipeline/items_client.go +++ b/fabric/datapipeline/items_client.go @@ -382,7 +382,15 @@ func (client *ItemsClient) updateDataPipelineHandleResponse(resp *http.Response) // - createDataPipelineRequest - Create item request payload. // - options - ItemsClientBeginCreateDataPipelineOptions contains the optional parameters for the ItemsClient.BeginCreateDataPipeline method. func (client *ItemsClient) CreateDataPipeline(ctx context.Context, workspaceID string, createDataPipelineRequest CreateDataPipelineRequest, options *ItemsClientBeginCreateDataPipelineOptions) (ItemsClientCreateDataPipelineResponse, error) { - return iruntime.NewLRO(client.BeginCreateDataPipeline(ctx, workspaceID, createDataPipelineRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateDataPipeline(ctx, workspaceID, createDataPipelineRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateDataPipelineResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateDataPipelineResponse{}, err + } + return result, err } // beginCreateDataPipeline creates the createDataPipeline request. @@ -448,7 +456,11 @@ func (client *ItemsClient) ListDataPipelines(ctx context.Context, workspaceID st } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []DataPipeline{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []DataPipeline{}, err } return list, nil } diff --git a/fabric/environment/items_client.go b/fabric/environment/items_client.go index a55a9da..e8df8de 100644 --- a/fabric/environment/items_client.go +++ b/fabric/environment/items_client.go @@ -383,7 +383,15 @@ func (client *ItemsClient) updateEnvironmentHandleResponse(resp *http.Response) // - createEnvironmentRequest - Create item request payload. // - options - ItemsClientBeginCreateEnvironmentOptions contains the optional parameters for the ItemsClient.BeginCreateEnvironment method. func (client *ItemsClient) CreateEnvironment(ctx context.Context, workspaceID string, createEnvironmentRequest CreateEnvironmentRequest, options *ItemsClientBeginCreateEnvironmentOptions) (ItemsClientCreateEnvironmentResponse, error) { - return iruntime.NewLRO(client.BeginCreateEnvironment(ctx, workspaceID, createEnvironmentRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateEnvironment(ctx, workspaceID, createEnvironmentRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateEnvironmentResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateEnvironmentResponse{}, err + } + return result, err } // beginCreateEnvironment creates the createEnvironment request. @@ -449,7 +457,11 @@ func (client *ItemsClient) ListEnvironments(ctx context.Context, workspaceID str } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Environment{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []Environment{}, err } return list, nil } diff --git a/fabric/eventhouse/items_client.go b/fabric/eventhouse/items_client.go index 73917f1..317c7da 100644 --- a/fabric/eventhouse/items_client.go +++ b/fabric/eventhouse/items_client.go @@ -382,7 +382,15 @@ func (client *ItemsClient) updateEventhouseHandleResponse(resp *http.Response) ( // - createEventhouseRequest - Create eventhouse request payload. // - options - ItemsClientBeginCreateEventhouseOptions contains the optional parameters for the ItemsClient.BeginCreateEventhouse method. func (client *ItemsClient) CreateEventhouse(ctx context.Context, workspaceID string, createEventhouseRequest CreateEventhouseRequest, options *ItemsClientBeginCreateEventhouseOptions) (ItemsClientCreateEventhouseResponse, error) { - return iruntime.NewLRO(client.BeginCreateEventhouse(ctx, workspaceID, createEventhouseRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateEventhouse(ctx, workspaceID, createEventhouseRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateEventhouseResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateEventhouseResponse{}, err + } + return result, err } // beginCreateEventhouse creates the createEventhouse request. @@ -448,7 +456,11 @@ func (client *ItemsClient) ListEventhouses(ctx context.Context, workspaceID stri } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Eventhouse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []Eventhouse{}, err } return list, nil } diff --git a/fabric/eventstream/items_client.go b/fabric/eventstream/items_client.go index ff697c5..7600306 100644 --- a/fabric/eventstream/items_client.go +++ b/fabric/eventstream/items_client.go @@ -386,7 +386,15 @@ func (client *ItemsClient) updateEventstreamHandleResponse(resp *http.Response) // - createEventstreamRequest - Create item request payload. // - options - ItemsClientBeginCreateEventstreamOptions contains the optional parameters for the ItemsClient.BeginCreateEventstream method. func (client *ItemsClient) CreateEventstream(ctx context.Context, workspaceID string, createEventstreamRequest CreateEventstreamRequest, options *ItemsClientBeginCreateEventstreamOptions) (ItemsClientCreateEventstreamResponse, error) { - return iruntime.NewLRO(client.BeginCreateEventstream(ctx, workspaceID, createEventstreamRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateEventstream(ctx, workspaceID, createEventstreamRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateEventstreamResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateEventstreamResponse{}, err + } + return result, err } // beginCreateEventstream creates the createEventstream request. @@ -452,7 +460,11 @@ func (client *ItemsClient) ListEventstreams(ctx context.Context, workspaceID str } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Eventstream{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []Eventstream{}, err } return list, nil } diff --git a/fabric/kqldatabase/items_client.go b/fabric/kqldatabase/items_client.go index 7be5573..d9aba1e 100644 --- a/fabric/kqldatabase/items_client.go +++ b/fabric/kqldatabase/items_client.go @@ -382,7 +382,15 @@ func (client *ItemsClient) updateKQLDatabaseHandleResponse(resp *http.Response) // - createKQLDatabaseRequest - Create item request payload. // - options - ItemsClientBeginCreateKQLDatabaseOptions contains the optional parameters for the ItemsClient.BeginCreateKQLDatabase method. func (client *ItemsClient) CreateKQLDatabase(ctx context.Context, workspaceID string, createKQLDatabaseRequest CreateKQLDatabaseRequest, options *ItemsClientBeginCreateKQLDatabaseOptions) (ItemsClientCreateKQLDatabaseResponse, error) { - return iruntime.NewLRO(client.BeginCreateKQLDatabase(ctx, workspaceID, createKQLDatabaseRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateKQLDatabase(ctx, workspaceID, createKQLDatabaseRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateKQLDatabaseResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateKQLDatabaseResponse{}, err + } + return result, err } // beginCreateKQLDatabase creates the createKQLDatabase request. @@ -448,7 +456,11 @@ func (client *ItemsClient) ListKQLDatabases(ctx context.Context, workspaceID str } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []KQLDatabase{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []KQLDatabase{}, err } return list, nil } diff --git a/fabric/kqlqueryset/items_client.go b/fabric/kqlqueryset/items_client.go index 36d08c8..c31cd4e 100644 --- a/fabric/kqlqueryset/items_client.go +++ b/fabric/kqlqueryset/items_client.go @@ -305,7 +305,11 @@ func (client *ItemsClient) ListKQLQuerysets(ctx context.Context, workspaceID str } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []KQLQueryset{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []KQLQueryset{}, err } return list, nil } diff --git a/fabric/lakehouse/items_client.go b/fabric/lakehouse/items_client.go index 5304a29..d8338c1 100644 --- a/fabric/lakehouse/items_client.go +++ b/fabric/lakehouse/items_client.go @@ -377,7 +377,15 @@ func (client *ItemsClient) updateLakehouseHandleResponse(resp *http.Response) (I // - createLakehouseRequest - Create item request payload. // - options - ItemsClientBeginCreateLakehouseOptions contains the optional parameters for the ItemsClient.BeginCreateLakehouse method. func (client *ItemsClient) CreateLakehouse(ctx context.Context, workspaceID string, createLakehouseRequest CreateLakehouseRequest, options *ItemsClientBeginCreateLakehouseOptions) (ItemsClientCreateLakehouseResponse, error) { - return iruntime.NewLRO(client.BeginCreateLakehouse(ctx, workspaceID, createLakehouseRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateLakehouse(ctx, workspaceID, createLakehouseRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateLakehouseResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateLakehouseResponse{}, err + } + return result, err } // beginCreateLakehouse creates the createLakehouse request. @@ -443,7 +451,11 @@ func (client *ItemsClient) ListLakehouses(ctx context.Context, workspaceID strin } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Lakehouse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []Lakehouse{}, err } return list, nil } diff --git a/fabric/lakehouse/tables_client.go b/fabric/lakehouse/tables_client.go index d8614a2..55bfd30 100644 --- a/fabric/lakehouse/tables_client.go +++ b/fabric/lakehouse/tables_client.go @@ -206,7 +206,15 @@ func (client *TablesClient) loadTableCreateRequest(ctx context.Context, workspac // - loadTableRequest - The load table request payload. // - options - TablesClientBeginLoadTableOptions contains the optional parameters for the TablesClient.BeginLoadTable method. func (client *TablesClient) LoadTable(ctx context.Context, workspaceID string, lakehouseID string, tableName string, loadTableRequest LoadTableRequest, options *TablesClientBeginLoadTableOptions) (TablesClientLoadTableResponse, error) { - return iruntime.NewLRO(client.BeginLoadTable(ctx, workspaceID, lakehouseID, tableName, loadTableRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginLoadTable(ctx, workspaceID, lakehouseID, tableName, loadTableRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return TablesClientLoadTableResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return TablesClientLoadTableResponse{}, err + } + return result, err } // beginLoadTable creates the loadTable request. @@ -271,7 +279,11 @@ func (client *TablesClient) ListTables(ctx context.Context, workspaceID string, } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Table{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []Table{}, err } return list, nil } diff --git a/fabric/mirroredwarehouse/items_client.go b/fabric/mirroredwarehouse/items_client.go index ec6d405..efbb1ce 100644 --- a/fabric/mirroredwarehouse/items_client.go +++ b/fabric/mirroredwarehouse/items_client.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/microsoft/fabric-sdk-go/fabric/core" "github.com/microsoft/fabric-sdk-go/internal/iruntime" ) @@ -118,7 +119,11 @@ func (client *ItemsClient) ListMirroredWarehouses(ctx context.Context, workspace } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []MirroredWarehouse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []MirroredWarehouse{}, err } return list, nil } diff --git a/fabric/mlexperiment/items_client.go b/fabric/mlexperiment/items_client.go index 3149283..fd2bde4 100644 --- a/fabric/mlexperiment/items_client.go +++ b/fabric/mlexperiment/items_client.go @@ -391,7 +391,15 @@ func (client *ItemsClient) updateMLExperimentHandleResponse(resp *http.Response) // - createMLExperimentRequest - Create item request payload. // - options - ItemsClientBeginCreateMLExperimentOptions contains the optional parameters for the ItemsClient.BeginCreateMLExperiment method. func (client *ItemsClient) CreateMLExperiment(ctx context.Context, workspaceID string, createMLExperimentRequest CreateMLExperimentRequest, options *ItemsClientBeginCreateMLExperimentOptions) (ItemsClientCreateMLExperimentResponse, error) { - return iruntime.NewLRO(client.BeginCreateMLExperiment(ctx, workspaceID, createMLExperimentRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateMLExperiment(ctx, workspaceID, createMLExperimentRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateMLExperimentResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateMLExperimentResponse{}, err + } + return result, err } // beginCreateMLExperiment creates the createMLExperiment request. @@ -457,7 +465,11 @@ func (client *ItemsClient) ListMLExperiments(ctx context.Context, workspaceID st } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []MLExperiment{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []MLExperiment{}, err } return list, nil } diff --git a/fabric/mlmodel/items_client.go b/fabric/mlmodel/items_client.go index c97aa7c..1b1b792 100644 --- a/fabric/mlmodel/items_client.go +++ b/fabric/mlmodel/items_client.go @@ -390,7 +390,15 @@ func (client *ItemsClient) updateMLModelHandleResponse(resp *http.Response) (Ite // - createMLModelRequest - Create item request payload. // - options - ItemsClientBeginCreateMLModelOptions contains the optional parameters for the ItemsClient.BeginCreateMLModel method. func (client *ItemsClient) CreateMLModel(ctx context.Context, workspaceID string, createMLModelRequest CreateMLModelRequest, options *ItemsClientBeginCreateMLModelOptions) (ItemsClientCreateMLModelResponse, error) { - return iruntime.NewLRO(client.BeginCreateMLModel(ctx, workspaceID, createMLModelRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateMLModel(ctx, workspaceID, createMLModelRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateMLModelResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateMLModelResponse{}, err + } + return result, err } // beginCreateMLModel creates the createMLModel request. @@ -456,7 +464,11 @@ func (client *ItemsClient) ListMLModels(ctx context.Context, workspaceID string, } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []MLModel{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []MLModel{}, err } return list, nil } diff --git a/fabric/notebook/items_client.go b/fabric/notebook/items_client.go index fea42a8..fc1c929 100644 --- a/fabric/notebook/items_client.go +++ b/fabric/notebook/items_client.go @@ -552,7 +552,15 @@ func (client *ItemsClient) updateNotebookDefinitionCreateRequest(ctx context.Con // - createNotebookRequest - Create item request payload. // - options - ItemsClientBeginCreateNotebookOptions contains the optional parameters for the ItemsClient.BeginCreateNotebook method. func (client *ItemsClient) CreateNotebook(ctx context.Context, workspaceID string, createNotebookRequest CreateNotebookRequest, options *ItemsClientBeginCreateNotebookOptions) (ItemsClientCreateNotebookResponse, error) { - return iruntime.NewLRO(client.BeginCreateNotebook(ctx, workspaceID, createNotebookRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateNotebook(ctx, workspaceID, createNotebookRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateNotebookResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateNotebookResponse{}, err + } + return result, err } // beginCreateNotebook creates the createNotebook request. @@ -618,7 +626,15 @@ func (client *ItemsClient) beginCreateNotebook(ctx context.Context, workspaceID // - notebookID - The notebook ID. // - options - ItemsClientBeginGetNotebookDefinitionOptions contains the optional parameters for the ItemsClient.BeginGetNotebookDefinition method. func (client *ItemsClient) GetNotebookDefinition(ctx context.Context, workspaceID string, notebookID string, options *ItemsClientBeginGetNotebookDefinitionOptions) (ItemsClientGetNotebookDefinitionResponse, error) { - return iruntime.NewLRO(client.BeginGetNotebookDefinition(ctx, workspaceID, notebookID, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginGetNotebookDefinition(ctx, workspaceID, notebookID, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientGetNotebookDefinitionResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientGetNotebookDefinitionResponse{}, err + } + return result, err } // beginGetNotebookDefinition creates the getNotebookDefinition request. @@ -683,7 +699,15 @@ func (client *ItemsClient) beginGetNotebookDefinition(ctx context.Context, works // - updateNotebookDefinitionRequest - Update notebook definition request payload. // - options - ItemsClientBeginUpdateNotebookDefinitionOptions contains the optional parameters for the ItemsClient.BeginUpdateNotebookDefinition method. func (client *ItemsClient) UpdateNotebookDefinition(ctx context.Context, workspaceID string, notebookID string, updateNotebookDefinitionRequest UpdateNotebookDefinitionRequest, options *ItemsClientBeginUpdateNotebookDefinitionOptions) (ItemsClientUpdateNotebookDefinitionResponse, error) { - return iruntime.NewLRO(client.BeginUpdateNotebookDefinition(ctx, workspaceID, notebookID, updateNotebookDefinitionRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginUpdateNotebookDefinition(ctx, workspaceID, notebookID, updateNotebookDefinitionRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientUpdateNotebookDefinitionResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientUpdateNotebookDefinitionResponse{}, err + } + return result, err } // beginUpdateNotebookDefinition creates the updateNotebookDefinition request. @@ -749,7 +773,11 @@ func (client *ItemsClient) ListNotebooks(ctx context.Context, workspaceID string } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Notebook{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []Notebook{}, err } return list, nil } diff --git a/fabric/paginatedreport/items_client.go b/fabric/paginatedreport/items_client.go index 66136e3..5f9c9da 100644 --- a/fabric/paginatedreport/items_client.go +++ b/fabric/paginatedreport/items_client.go @@ -188,7 +188,11 @@ func (client *ItemsClient) ListPaginatedReports(ctx context.Context, workspaceID } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []PaginatedReport{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []PaginatedReport{}, err } return list, nil } diff --git a/fabric/report/items_client.go b/fabric/report/items_client.go index 9facc2d..957cebd 100644 --- a/fabric/report/items_client.go +++ b/fabric/report/items_client.go @@ -549,7 +549,15 @@ func (client *ItemsClient) updateReportDefinitionCreateRequest(ctx context.Conte // - createReportRequest - Create item request payload. // - options - ItemsClientBeginCreateReportOptions contains the optional parameters for the ItemsClient.BeginCreateReport method. func (client *ItemsClient) CreateReport(ctx context.Context, workspaceID string, createReportRequest CreateReportRequest, options *ItemsClientBeginCreateReportOptions) (ItemsClientCreateReportResponse, error) { - return iruntime.NewLRO(client.BeginCreateReport(ctx, workspaceID, createReportRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateReport(ctx, workspaceID, createReportRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateReportResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateReportResponse{}, err + } + return result, err } // beginCreateReport creates the createReport request. @@ -615,7 +623,15 @@ func (client *ItemsClient) beginCreateReport(ctx context.Context, workspaceID st // - reportID - The report ID. // - options - ItemsClientBeginGetReportDefinitionOptions contains the optional parameters for the ItemsClient.BeginGetReportDefinition method. func (client *ItemsClient) GetReportDefinition(ctx context.Context, workspaceID string, reportID string, options *ItemsClientBeginGetReportDefinitionOptions) (ItemsClientGetReportDefinitionResponse, error) { - return iruntime.NewLRO(client.BeginGetReportDefinition(ctx, workspaceID, reportID, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginGetReportDefinition(ctx, workspaceID, reportID, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientGetReportDefinitionResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientGetReportDefinitionResponse{}, err + } + return result, err } // beginGetReportDefinition creates the getReportDefinition request. @@ -680,7 +696,15 @@ func (client *ItemsClient) beginGetReportDefinition(ctx context.Context, workspa // - updateReportDefinitionRequest - Update report definition request payload. // - options - ItemsClientBeginUpdateReportDefinitionOptions contains the optional parameters for the ItemsClient.BeginUpdateReportDefinition method. func (client *ItemsClient) UpdateReportDefinition(ctx context.Context, workspaceID string, reportID string, updateReportDefinitionRequest UpdateReportDefinitionRequest, options *ItemsClientBeginUpdateReportDefinitionOptions) (ItemsClientUpdateReportDefinitionResponse, error) { - return iruntime.NewLRO(client.BeginUpdateReportDefinition(ctx, workspaceID, reportID, updateReportDefinitionRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginUpdateReportDefinition(ctx, workspaceID, reportID, updateReportDefinitionRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientUpdateReportDefinitionResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientUpdateReportDefinitionResponse{}, err + } + return result, err } // beginUpdateReportDefinition creates the updateReportDefinition request. @@ -746,7 +770,11 @@ func (client *ItemsClient) ListReports(ctx context.Context, workspaceID string, } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Report{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []Report{}, err } return list, nil } diff --git a/fabric/semanticmodel/items_client.go b/fabric/semanticmodel/items_client.go index ac04656..ddd98ad 100644 --- a/fabric/semanticmodel/items_client.go +++ b/fabric/semanticmodel/items_client.go @@ -554,7 +554,15 @@ func (client *ItemsClient) updateSemanticModelDefinitionCreateRequest(ctx contex // - createSemanticModelRequest - Create item request payload. // - options - ItemsClientBeginCreateSemanticModelOptions contains the optional parameters for the ItemsClient.BeginCreateSemanticModel method. func (client *ItemsClient) CreateSemanticModel(ctx context.Context, workspaceID string, createSemanticModelRequest CreateSemanticModelRequest, options *ItemsClientBeginCreateSemanticModelOptions) (ItemsClientCreateSemanticModelResponse, error) { - return iruntime.NewLRO(client.BeginCreateSemanticModel(ctx, workspaceID, createSemanticModelRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateSemanticModel(ctx, workspaceID, createSemanticModelRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateSemanticModelResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateSemanticModelResponse{}, err + } + return result, err } // beginCreateSemanticModel creates the createSemanticModel request. @@ -620,7 +628,15 @@ func (client *ItemsClient) beginCreateSemanticModel(ctx context.Context, workspa // - semanticModelID - The semantic model ID. // - options - ItemsClientBeginGetSemanticModelDefinitionOptions contains the optional parameters for the ItemsClient.BeginGetSemanticModelDefinition method. func (client *ItemsClient) GetSemanticModelDefinition(ctx context.Context, workspaceID string, semanticModelID string, options *ItemsClientBeginGetSemanticModelDefinitionOptions) (ItemsClientGetSemanticModelDefinitionResponse, error) { - return iruntime.NewLRO(client.BeginGetSemanticModelDefinition(ctx, workspaceID, semanticModelID, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginGetSemanticModelDefinition(ctx, workspaceID, semanticModelID, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientGetSemanticModelDefinitionResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientGetSemanticModelDefinitionResponse{}, err + } + return result, err } // beginGetSemanticModelDefinition creates the getSemanticModelDefinition request. @@ -685,7 +701,15 @@ func (client *ItemsClient) beginGetSemanticModelDefinition(ctx context.Context, // - updateSemanticModelDefinitionRequest - Update semantic model definition request payload. // - options - ItemsClientBeginUpdateSemanticModelDefinitionOptions contains the optional parameters for the ItemsClient.BeginUpdateSemanticModelDefinition method. func (client *ItemsClient) UpdateSemanticModelDefinition(ctx context.Context, workspaceID string, semanticModelID string, updateSemanticModelDefinitionRequest UpdateSemanticModelDefinitionRequest, options *ItemsClientBeginUpdateSemanticModelDefinitionOptions) (ItemsClientUpdateSemanticModelDefinitionResponse, error) { - return iruntime.NewLRO(client.BeginUpdateSemanticModelDefinition(ctx, workspaceID, semanticModelID, updateSemanticModelDefinitionRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginUpdateSemanticModelDefinition(ctx, workspaceID, semanticModelID, updateSemanticModelDefinitionRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientUpdateSemanticModelDefinitionResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientUpdateSemanticModelDefinitionResponse{}, err + } + return result, err } // beginUpdateSemanticModelDefinition creates the updateSemanticModelDefinition request. @@ -751,7 +775,11 @@ func (client *ItemsClient) ListSemanticModels(ctx context.Context, workspaceID s } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []SemanticModel{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []SemanticModel{}, err } return list, nil } diff --git a/fabric/spark/custompools_client.go b/fabric/spark/custompools_client.go index e921976..2f19998 100644 --- a/fabric/spark/custompools_client.go +++ b/fabric/spark/custompools_client.go @@ -372,7 +372,11 @@ func (client *CustomPoolsClient) ListWorkspaceCustomPools(ctx context.Context, w } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []CustomPool{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []CustomPool{}, err } return list, nil } diff --git a/fabric/sparkjobdefinition/items_client.go b/fabric/sparkjobdefinition/items_client.go index 0ff703a..b6f8046 100644 --- a/fabric/sparkjobdefinition/items_client.go +++ b/fabric/sparkjobdefinition/items_client.go @@ -559,7 +559,15 @@ func (client *ItemsClient) updateSparkJobDefinitionDefinitionCreateRequest(ctx c // - createSparkJobDefinitionRequest - Create item request payload. // - options - ItemsClientBeginCreateSparkJobDefinitionOptions contains the optional parameters for the ItemsClient.BeginCreateSparkJobDefinition method. func (client *ItemsClient) CreateSparkJobDefinition(ctx context.Context, workspaceID string, createSparkJobDefinitionRequest CreateSparkJobDefinitionRequest, options *ItemsClientBeginCreateSparkJobDefinitionOptions) (ItemsClientCreateSparkJobDefinitionResponse, error) { - return iruntime.NewLRO(client.BeginCreateSparkJobDefinition(ctx, workspaceID, createSparkJobDefinitionRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateSparkJobDefinition(ctx, workspaceID, createSparkJobDefinitionRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateSparkJobDefinitionResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateSparkJobDefinitionResponse{}, err + } + return result, err } // beginCreateSparkJobDefinition creates the createSparkJobDefinition request. @@ -625,7 +633,15 @@ func (client *ItemsClient) beginCreateSparkJobDefinition(ctx context.Context, wo // - sparkJobDefinitionID - The spark job definition ID. // - options - ItemsClientBeginGetSparkJobDefinitionDefinitionOptions contains the optional parameters for the ItemsClient.BeginGetSparkJobDefinitionDefinition method. func (client *ItemsClient) GetSparkJobDefinitionDefinition(ctx context.Context, workspaceID string, sparkJobDefinitionID string, options *ItemsClientBeginGetSparkJobDefinitionDefinitionOptions) (ItemsClientGetSparkJobDefinitionDefinitionResponse, error) { - return iruntime.NewLRO(client.BeginGetSparkJobDefinitionDefinition(ctx, workspaceID, sparkJobDefinitionID, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginGetSparkJobDefinitionDefinition(ctx, workspaceID, sparkJobDefinitionID, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientGetSparkJobDefinitionDefinitionResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientGetSparkJobDefinitionDefinitionResponse{}, err + } + return result, err } // beginGetSparkJobDefinitionDefinition creates the getSparkJobDefinitionDefinition request. @@ -690,7 +706,15 @@ func (client *ItemsClient) beginGetSparkJobDefinitionDefinition(ctx context.Cont // - updateSparkJobDefinitionRequest - Update spark job definition definition request payload. // - options - ItemsClientBeginUpdateSparkJobDefinitionDefinitionOptions contains the optional parameters for the ItemsClient.BeginUpdateSparkJobDefinitionDefinition method. func (client *ItemsClient) UpdateSparkJobDefinitionDefinition(ctx context.Context, workspaceID string, sparkJobDefinitionID string, updateSparkJobDefinitionRequest UpdateSparkJobDefinitionDefinitionRequest, options *ItemsClientBeginUpdateSparkJobDefinitionDefinitionOptions) (ItemsClientUpdateSparkJobDefinitionDefinitionResponse, error) { - return iruntime.NewLRO(client.BeginUpdateSparkJobDefinitionDefinition(ctx, workspaceID, sparkJobDefinitionID, updateSparkJobDefinitionRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginUpdateSparkJobDefinitionDefinition(ctx, workspaceID, sparkJobDefinitionID, updateSparkJobDefinitionRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientUpdateSparkJobDefinitionDefinitionResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientUpdateSparkJobDefinitionDefinitionResponse{}, err + } + return result, err } // beginUpdateSparkJobDefinitionDefinition creates the updateSparkJobDefinitionDefinition request. @@ -756,7 +780,11 @@ func (client *ItemsClient) ListSparkJobDefinitions(ctx context.Context, workspac } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []SparkJobDefinition{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []SparkJobDefinition{}, err } return list, nil } diff --git a/fabric/sqlendpoint/items_client.go b/fabric/sqlendpoint/items_client.go index 9b3249c..ff47aa4 100644 --- a/fabric/sqlendpoint/items_client.go +++ b/fabric/sqlendpoint/items_client.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/microsoft/fabric-sdk-go/fabric/core" "github.com/microsoft/fabric-sdk-go/internal/iruntime" ) @@ -118,7 +119,11 @@ func (client *ItemsClient) ListSQLEndpoints(ctx context.Context, workspaceID str } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []SQLEndpoint{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []SQLEndpoint{}, err } return list, nil } diff --git a/fabric/warehouse/items_client.go b/fabric/warehouse/items_client.go index 6c6407e..7e02f90 100644 --- a/fabric/warehouse/items_client.go +++ b/fabric/warehouse/items_client.go @@ -386,7 +386,15 @@ func (client *ItemsClient) updateWarehouseHandleResponse(resp *http.Response) (I // - createWarehouseRequest - Create item request payload. // - options - ItemsClientBeginCreateWarehouseOptions contains the optional parameters for the ItemsClient.BeginCreateWarehouse method. func (client *ItemsClient) CreateWarehouse(ctx context.Context, workspaceID string, createWarehouseRequest CreateWarehouseRequest, options *ItemsClientBeginCreateWarehouseOptions) (ItemsClientCreateWarehouseResponse, error) { - return iruntime.NewLRO(client.BeginCreateWarehouse(ctx, workspaceID, createWarehouseRequest, options)).Sync(ctx) + result, err := iruntime.NewLRO(client.BeginCreateWarehouse(ctx, workspaceID, createWarehouseRequest, options)).Sync(ctx) + if err != nil { + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return ItemsClientCreateWarehouseResponse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return ItemsClientCreateWarehouseResponse{}, err + } + return result, err } // beginCreateWarehouse creates the createWarehouse request. @@ -452,7 +460,11 @@ func (client *ItemsClient) ListWarehouses(ctx context.Context, workspaceID strin } list, err := iruntime.NewPageIterator(ctx, pager, mapper).Get() if err != nil { - return nil, err + var azcoreRespError *azcore.ResponseError + if errors.As(err, &azcoreRespError) { + return []Warehouse{}, core.NewResponseError(azcoreRespError.RawResponse) + } + return []Warehouse{}, err } return list, nil } diff --git a/internal/iruntime/service_client.go b/internal/iruntime/service_client.go index fe5fbba..857fef2 100644 --- a/internal/iruntime/service_client.go +++ b/internal/iruntime/service_client.go @@ -19,7 +19,7 @@ import ( ) const ( - moduleVersion = "0.1.0-beta.1" + moduleVersion = "0.1.0-beta.2" defaultApiEndpoint = "https://api.fabric.microsoft.com" )