Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new resource synapse_big_data_pool #7886

Merged
merged 7 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions azurerm/internal/services/synapse/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ import (
)

type Client struct {
BigDataPoolClient *synapse.BigDataPoolsClient
FirewallRulesClient *synapse.IPFirewallRulesClient
WorkspaceClient *synapse.WorkspacesClient
WorkspaceAadAdminsClient *synapse.WorkspaceAadAdminsClient
}

func NewClient(o *common.ClientOptions) *Client {
bigDataPoolClient := synapse.NewBigDataPoolsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&bigDataPoolClient.Client, o.ResourceManagerAuthorizer)

firewallRuleClient := synapse.NewIPFirewallRulesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&firewallRuleClient.Client, o.ResourceManagerAuthorizer)

Expand All @@ -22,6 +26,7 @@ func NewClient(o *common.ClientOptions) *Client {
o.ConfigureClient(&workspaceAadAdminsClient.Client, o.ResourceManagerAuthorizer)

return &Client{
BigDataPoolClient: &bigDataPoolClient,
FirewallRulesClient: &firewallRuleClient,
WorkspaceClient: &workspaceClient,
WorkspaceAadAdminsClient: &workspaceAadAdminsClient,
Expand Down
37 changes: 37 additions & 0 deletions azurerm/internal/services/synapse/parse/synapse_big_data_pool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package parse

import (
"fmt"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
)

type SynapseBigDataPoolId struct {
Workspace *SynapseWorkspaceId
Name string
}

func SynapseBigDataPoolID(input string) (*SynapseBigDataPoolId, error) {
id, err := azure.ParseAzureResourceID(input)
if err != nil {
return nil, fmt.Errorf("parsing synapseBigDataPool ID %q: %+v", input, err)
}

synapseBigDataPool := SynapseBigDataPoolId{
Workspace: &SynapseWorkspaceId{
SubscriptionID: id.SubscriptionID,
ResourceGroup: id.ResourceGroup,
},
}
if synapseBigDataPool.Workspace.Name, err = id.PopSegment("workspaces"); err != nil {
return nil, err
}
if synapseBigDataPool.Name, err = id.PopSegment("bigDataPools"); err != nil {
return nil, err
}
if err := id.ValidateNoEmptySegments(input); err != nil {
return nil, err
}

return &synapseBigDataPool, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package parse

import (
"testing"
)

func TestSynapseBigDataPoolID(t *testing.T) {
testData := []struct {
Name string
Input string
Expected *SynapseBigDataPoolId
}{
{
Name: "Empty",
Input: "",
Expected: nil,
},
{
Name: "No Resource Groups Segment",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000",
Expected: nil,
},
{
Name: "No Resource Groups Value",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/",
Expected: nil,
},
{
Name: "Resource Group ID",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/",
Expected: nil,
},
{
Name: "Missing BigDataPool Value",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Synapse/workspaces/workspace1/bigDataPools",
Expected: nil,
},
{
Name: "synapse BigDataPool ID",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Synapse/workspaces/workspace1/bigDataPools/bigDataPool1",
Expected: &SynapseBigDataPoolId{
Workspace: &SynapseWorkspaceId{
ResourceGroup: "resourceGroup1",
Name: "workspace1",
},
Name: "bigDataPool1",
},
},
{
Name: "Wrong Casing",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Synapse/workspaces/workspace1/BigDataPools/bigDataPool1",
Expected: nil,
},
}

for _, v := range testData {
t.Logf("[DEBUG] Testing %q..", v.Name)

actual, err := SynapseBigDataPoolID(v.Input)
if err != nil {
if v.Expected == nil {
continue
}
t.Fatalf("Expected a value but got an error: %s", err)
}

if actual.Workspace.ResourceGroup != v.Expected.Workspace.ResourceGroup {
t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.Workspace.ResourceGroup, actual.Workspace.ResourceGroup)
}

if actual.Workspace.Name != v.Expected.Workspace.Name {
t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.Workspace.Name, actual.Workspace.Name)
}

if actual.Name != v.Expected.Name {
t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name)
}
}
}
1 change: 1 addition & 0 deletions azurerm/internal/services/synapse/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (r Registration) SupportedDataSources() map[string]*schema.Resource {
// SupportedResources returns the supported Resources supported by this Service
func (r Registration) SupportedResources() map[string]*schema.Resource {
return map[string]*schema.Resource{
"azurerm_synapse_big_data_pool": resourceArmSynapseBigDataPool(),
"azurerm_synapse_firewall_rule": resourceArmSynapseFirewallRule(),
"azurerm_synapse_workspace": resourceArmSynapseWorkspace(),
}
Expand Down
Loading