forked from hashicorp/terraform-provider-azurerm
/
namespace.go
33 lines (25 loc) · 847 Bytes
/
namespace.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
package parse
import (
"fmt"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
)
type ServiceBusNamespaceId struct {
Name string
ResourceGroup string
}
func ServiceBusNamespaceID(input string) (*ServiceBusNamespaceId, error) {
id, err := azure.ParseAzureResourceID(input)
if err != nil {
return nil, fmt.Errorf("unable to parse Service Bus Namespace ID %q: %+v", input, err)
}
namespace := ServiceBusNamespaceId{
ResourceGroup: id.ResourceGroup,
}
if namespace.Name, err = id.PopSegment("namespaces"); err != nil {
return nil, fmt.Errorf("unable to parse Service Bus Namespace ID %q: %+v", input, err)
}
if err := id.ValidateNoEmptySegments(input); err != nil {
return nil, fmt.Errorf("unable to parse Service Bus Namespace ID %q: %+v", input, err)
}
return &namespace, nil
}