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

eventhub: updating the namespace SDK to use API Version 2021-01-01-preview #12290

Merged
merged 2 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func resourceEventHubNamespaceCustomerManagedKeyCreateUpdate(d *pluginsdk.Resour
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

id, err := namespaces.NamespaceID(d.Get("eventhub_namespace_id").(string))
id, err := namespaces.ParseNamespaceID(d.Get("eventhub_namespace_id").(string))
if err != nil {
return err
}
Expand Down Expand Up @@ -107,7 +107,7 @@ func resourceEventHubNamespaceCustomerManagedKeyRead(d *pluginsdk.ResourceData,
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

id, err := namespaces.NamespaceID(d.Id())
id, err := namespaces.ParseNamespaceID(d.Id())
if err != nil {
return err
}
Expand Down Expand Up @@ -147,7 +147,7 @@ func resourceEventHubNamespaceCustomerManagedKeyDelete(d *pluginsdk.ResourceData
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()

id, err := namespaces.NamespaceID(d.Id())
id, err := namespaces.ParseNamespaceID(d.Id())
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestAccEventHubNamespaceCustomerManagedKey_update(t *testing.T) {
}

func (r EventHubNamespaceCustomerManagedKeyResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := namespaces.NamespaceID(state.ID)
id, err := namespaces.ParseNamespaceID(state.ID)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func resourceEventHubNamespaceRead(d *pluginsdk.ResourceData, meta interface{})
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

id, err := namespaces.NamespaceID(d.Id())
id, err := namespaces.ParseNamespaceID(d.Id())
if err != nil {
return err
}
Expand Down Expand Up @@ -429,7 +429,7 @@ func resourceEventHubNamespaceDelete(d *pluginsdk.ResourceData, meta interface{}
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()

id, err := namespaces.NamespaceID(d.Id())
id, err := namespaces.ParseNamespaceID(d.Id())
if err != nil {
return err
}
Expand Down Expand Up @@ -601,8 +601,8 @@ func expandEventHubIdentity(input []interface{}) *namespaces.Identity {

v := input[0].(map[string]interface{})
return &namespaces.Identity{
Type: func() *namespaces.IdentityType {
v := namespaces.IdentityType(v["type"].(string))
Type: func() *namespaces.ManagedServiceIdentityType {
v := namespaces.ManagedServiceIdentityType(v["type"].(string))
return &v
}(),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func TestAccEventHubNamespace_autoInfalteDisabledWithAutoInflateUnits(t *testing
}

func (EventHubNamespaceResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := namespaces.NamespaceID(state.ID)
id, err := namespaces.ParseNamespaceID(state.ID)
if err != nil {
return nil, err
}
Expand Down
38 changes: 36 additions & 2 deletions azurerm/internal/services/eventhub/sdk/namespaces/constants.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
package namespaces

type IdentityType string
type CreatedByType string

const (
IdentityTypeSystemAssigned IdentityType = "SystemAssigned"
CreatedByTypeApplication CreatedByType = "Application"
CreatedByTypeKey CreatedByType = "Key"
CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity"
CreatedByTypeUser CreatedByType = "User"
)

type EndPointProvisioningState string

const (
EndPointProvisioningStateCanceled EndPointProvisioningState = "Canceled"
EndPointProvisioningStateCreating EndPointProvisioningState = "Creating"
EndPointProvisioningStateDeleting EndPointProvisioningState = "Deleting"
EndPointProvisioningStateFailed EndPointProvisioningState = "Failed"
EndPointProvisioningStateSucceeded EndPointProvisioningState = "Succeeded"
EndPointProvisioningStateUpdating EndPointProvisioningState = "Updating"
)

type KeySource string
Expand All @@ -12,16 +26,36 @@ const (
KeySourceMicrosoftKeyVault KeySource = "Microsoft.KeyVault"
)

type ManagedServiceIdentityType string

const (
ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None"
ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned"
ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned, UserAssigned"
ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned"
)

type PrivateLinkConnectionStatus string

const (
PrivateLinkConnectionStatusApproved PrivateLinkConnectionStatus = "Approved"
PrivateLinkConnectionStatusDisconnected PrivateLinkConnectionStatus = "Disconnected"
PrivateLinkConnectionStatusPending PrivateLinkConnectionStatus = "Pending"
PrivateLinkConnectionStatusRejected PrivateLinkConnectionStatus = "Rejected"
)

type SkuName string

const (
SkuNameBasic SkuName = "Basic"
SkuNamePremium SkuName = "Premium"
SkuNameStandard SkuName = "Standard"
)

type SkuTier string

const (
SkuTierBasic SkuTier = "Basic"
SkuTierPremium SkuTier = "Premium"
SkuTierStandard SkuTier = "Standard"
)
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func (id NamespaceId) ID() string {
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name)
}

// NamespaceID parses a Namespace ID into an NamespaceId struct
func NamespaceID(input string) (*NamespaceId, error) {
// ParseNamespaceID parses a Namespace ID into an NamespaceId struct
func ParseNamespaceID(input string) (*NamespaceId, error) {
id, err := resourceids.ParseAzureResourceID(input)
if err != nil {
return nil, err
Expand Down Expand Up @@ -66,10 +66,10 @@ func NamespaceID(input string) (*NamespaceId, error) {
return &resourceId, nil
}

// NamespaceIDInsensitively parses an Namespace ID into an NamespaceId struct, insensitively
// ParseNamespaceIDInsensitively parses an Namespace ID into an NamespaceId struct, insensitively
// This should only be used to parse an ID for rewriting to a consistent casing,
// the NamespaceID method should be used instead for validation etc.
func NamespaceIDInsensitively(input string) (*NamespaceId, error) {
// the ParseNamespaceID method should be used instead for validation etc.
func ParseNamespaceIDInsensitively(input string) (*NamespaceId, error) {
id, err := resourceids.ParseAzureResourceID(input)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestNamespaceIDFormatter(t *testing.T) {
}
}

func TestNamespaceID(t *testing.T) {
func TestParseNamespaceID(t *testing.T) {
testData := []struct {
Input string
Error bool
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestNamespaceID(t *testing.T) {
for _, v := range testData {
t.Logf("[DEBUG] Testing %q", v.Input)

actual, err := NamespaceID(v.Input)
actual, err := ParseNamespaceID(v.Input)
if err != nil {
if v.Error {
continue
Expand All @@ -109,7 +109,7 @@ func TestNamespaceID(t *testing.T) {
}
}

func TestNamespaceIDInsensitively(t *testing.T) {
func TestParseNamespaceIDInsensitively(t *testing.T) {
testData := []struct {
Input string
Error bool
Expand Down Expand Up @@ -202,7 +202,7 @@ func TestNamespaceIDInsensitively(t *testing.T) {
for _, v := range testData {
t.Logf("[DEBUG] Testing %q", v.Input)

actual, err := NamespaceIDInsensitively(v.Input)
actual, err := ParseNamespaceIDInsensitively(v.Input)
if err != nil {
if v.Error {
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func (id ResourceGroupId) ID() string {
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup)
}

// ResourceGroupID parses a ResourceGroup ID into an ResourceGroupId struct
func ResourceGroupID(input string) (*ResourceGroupId, error) {
// ParseResourceGroupID parses a ResourceGroup ID into an ResourceGroupId struct
func ParseResourceGroupID(input string) (*ResourceGroupId, error) {
id, err := resourceids.ParseAzureResourceID(input)
if err != nil {
return nil, err
Expand All @@ -59,10 +59,10 @@ func ResourceGroupID(input string) (*ResourceGroupId, error) {
return &resourceId, nil
}

// ResourceGroupIDInsensitively parses an ResourceGroup ID into an ResourceGroupId struct, insensitively
// ParseResourceGroupIDInsensitively parses an ResourceGroup ID into an ResourceGroupId struct, insensitively
// This should only be used to parse an ID for rewriting to a consistent casing,
// the ResourceGroupID method should be used instead for validation etc.
func ResourceGroupIDInsensitively(input string) (*ResourceGroupId, error) {
// the ParseResourceGroupID method should be used instead for validation etc.
func ParseResourceGroupIDInsensitively(input string) (*ResourceGroupId, error) {
id, err := resourceids.ParseAzureResourceID(input)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestResourceGroupIDFormatter(t *testing.T) {
}
}

func TestResourceGroupID(t *testing.T) {
func TestParseResourceGroupID(t *testing.T) {
testData := []struct {
Input string
Error bool
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestResourceGroupID(t *testing.T) {
for _, v := range testData {
t.Logf("[DEBUG] Testing %q", v.Input)

actual, err := ResourceGroupID(v.Input)
actual, err := ParseResourceGroupID(v.Input)
if err != nil {
if v.Error {
continue
Expand All @@ -93,7 +93,7 @@ func TestResourceGroupID(t *testing.T) {
}
}

func TestResourceGroupIDInsensitively(t *testing.T) {
func TestParseResourceGroupIDInsensitively(t *testing.T) {
testData := []struct {
Input string
Error bool
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestResourceGroupIDInsensitively(t *testing.T) {
for _, v := range testData {
t.Logf("[DEBUG] Testing %q", v.Input)

actual, err := ResourceGroupIDInsensitively(v.Input)
actual, err := ParseResourceGroupIDInsensitively(v.Input)
if err != nil {
if v.Error {
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (c NamespacesClient) preparerForGet(ctx context.Context, id NamespaceId) (*
func (c NamespacesClient) responderForGet(resp *http.Response) (result GetResponse, err error) {
err = autorest.Respond(
resp,
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result.Model),
autorest.ByClosing())
result.HttpResponse = resp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (c NamespacesClient) preparerForUpdate(ctx context.Context, id NamespaceId,
func (c NamespacesClient) responderForUpdate(resp *http.Response) (result UpdateResponse, err error) {
err = autorest.Respond(
resp,
azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK, http.StatusCreated),
azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusCreated, http.StatusOK),
autorest.ByUnmarshallingJSON(&result.Model),
autorest.ByClosing())
result.HttpResponse = resp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package namespaces

type ConnectionState struct {
Description *string `json:"description,omitempty"`
Status *PrivateLinkConnectionStatus `json:"status,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type EHNamespace struct {
Name *string `json:"name,omitempty"`
Properties *EHNamespaceProperties `json:"properties,omitempty"`
Sku *Sku `json:"sku,omitempty"`
SystemData *SystemData `json:"systemData,omitempty"`
Tags *map[string]string `json:"tags,omitempty"`
Type *string `json:"type,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ import (
)

type EHNamespaceProperties struct {
ClusterArmId *string `json:"clusterArmId,omitempty"`
CreatedAt *string `json:"createdAt,omitempty"`
Encryption *Encryption `json:"encryption,omitempty"`
IsAutoInflateEnabled *bool `json:"isAutoInflateEnabled,omitempty"`
KafkaEnabled *bool `json:"kafkaEnabled,omitempty"`
MaximumThroughputUnits *int64 `json:"maximumThroughputUnits,omitempty"`
MetricId *string `json:"metricId,omitempty"`
ProvisioningState *string `json:"provisioningState,omitempty"`
ServiceBusEndpoint *string `json:"serviceBusEndpoint,omitempty"`
UpdatedAt *string `json:"updatedAt,omitempty"`
ZoneRedundant *bool `json:"zoneRedundant,omitempty"`
ClusterArmId *string `json:"clusterArmId,omitempty"`
CreatedAt *string `json:"createdAt,omitempty"`
Encryption *Encryption `json:"encryption,omitempty"`
IsAutoInflateEnabled *bool `json:"isAutoInflateEnabled,omitempty"`
KafkaEnabled *bool `json:"kafkaEnabled,omitempty"`
MaximumThroughputUnits *int64 `json:"maximumThroughputUnits,omitempty"`
MetricId *string `json:"metricId,omitempty"`
PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"`
ProvisioningState *string `json:"provisioningState,omitempty"`
ServiceBusEndpoint *string `json:"serviceBusEndpoint,omitempty"`
Status *string `json:"status,omitempty"`
UpdatedAt *string `json:"updatedAt,omitempty"`
ZoneRedundant *bool `json:"zoneRedundant,omitempty"`
}

func (o EHNamespaceProperties) ListCreatedAtAsTime() (*time.Time, error) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package namespaces

type Encryption struct {
KeySource *KeySource `json:"keySource,omitempty"`
KeyVaultProperties *[]KeyVaultProperties `json:"keyVaultProperties,omitempty"`
KeySource *KeySource `json:"keySource,omitempty"`
KeyVaultProperties *[]KeyVaultProperties `json:"keyVaultProperties,omitempty"`
RequireInfrastructureEncryption *bool `json:"requireInfrastructureEncryption,omitempty"`
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package namespaces

type Identity struct {
PrincipalId *string `json:"principalId,omitempty"`
TenantId *string `json:"tenantId,omitempty"`
Type *IdentityType `json:"type,omitempty"`
PrincipalId *string `json:"principalId,omitempty"`
TenantId *string `json:"tenantId,omitempty"`
Type *ManagedServiceIdentityType `json:"type,omitempty"`
UserAssignedIdentities *UserAssignedIdentityProperties `json:"userAssignedIdentities,omitempty"`
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package namespaces

type KeyVaultProperties struct {
KeyName *string `json:"keyName,omitempty"`
KeyVaultUri *string `json:"keyVaultUri,omitempty"`
KeyVersion *string `json:"keyVersion,omitempty"`
Identity *UserAssignedIdentityProperties `json:"identity,omitempty"`
KeyName *string `json:"keyName,omitempty"`
KeyVaultUri *string `json:"keyVaultUri,omitempty"`
KeyVersion *string `json:"keyVersion,omitempty"`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package namespaces

type PrivateEndpoint struct {
Id *string `json:"id,omitempty"`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package namespaces

type PrivateEndpointConnection struct {
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"`
SystemData *SystemData `json:"systemData,omitempty"`
Type *string `json:"type,omitempty"`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package namespaces

type PrivateEndpointConnectionProperties struct {
PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"`
PrivateLinkServiceConnectionState *ConnectionState `json:"privateLinkServiceConnectionState,omitempty"`
ProvisioningState *EndPointProvisioningState `json:"provisioningState,omitempty"`
}
Loading