/
namespace_network_rule.go
38 lines (29 loc) · 1.09 KB
/
namespace_network_rule.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package parse
import (
"fmt"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
)
type ServiceBusNamespaceNetworkRuleId struct {
Name string
NamespaceName string
ResourceGroup string
}
func ServiceBusNamespaceNetworkRuleID(input string) (*ServiceBusNamespaceNetworkRuleId, error) {
id, err := azure.ParseAzureResourceID(input)
if err != nil {
return nil, fmt.Errorf("unable to parse Service Bus Namespace Network Rule ID %q: %+v", input, err)
}
rule := ServiceBusNamespaceNetworkRuleId{
ResourceGroup: id.ResourceGroup,
}
if rule.Name, err = id.PopSegment("networkrulesets"); err != nil {
return nil, fmt.Errorf("unable to parse Service Bus Namespace Network Rule ID %q: %+v", input, err)
}
if rule.NamespaceName, err = id.PopSegment("namespaces"); err != nil {
return nil, fmt.Errorf("unable to parse Service Bus Namespace Network Rule ID %q: %+v", input, err)
}
if err := id.ValidateNoEmptySegments(input); err != nil {
return nil, fmt.Errorf("unable to parse Service Bus Namespace Network Rule ID %q: %+v", input, err)
}
return &rule, nil
}