package arm
import "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
Package arm contains functionality specific to Azure Resource Manager clients.
Index ¶
- Variables
- type ClientOptions
- type ResourceID
- type ResourceType
- func NewResourceType(providerNamespace, typeName string) ResourceType
- func ParseResourceType(resourceIDOrType string) (ResourceType, error)
- func (t ResourceType) AppendChild(childType string) ResourceType
- func (t ResourceType) IsParentOf(child ResourceType) bool
- func (t ResourceType) String() string
Examples ¶
Variables ¶
var ProviderResourceType = NewResourceType(builtInResourceNamespace, "providers")
ProviderResourceType is the ResourceType of a provider
var ResourceGroupResourceType = NewResourceType(builtInResourceNamespace, "resourceGroups")
ResourceGroupResourceType is the ResourceType of a resource group
var RootResourceID = &ResourceID{ Parent: nil, ResourceType: TenantResourceType, Name: "", }
RootResourceID defines the tenant as the root parent of all other ResourceID.
var SubscriptionResourceType = NewResourceType(builtInResourceNamespace, "subscriptions")
SubscriptionResourceType is the ResourceType of a subscription
var TenantResourceType = NewResourceType(builtInResourceNamespace, "tenants")
TenantResourceType is the ResourceType of a tenant
Types ¶
type ClientOptions ¶
type ClientOptions struct { policy.ClientOptions // AuxiliaryTenants contains a list of additional tenants for cross-tenant requests. AuxiliaryTenants []string // DisableRPRegistration disables the auto-RP registration policy. Defaults to false. DisableRPRegistration bool }
ClientOptions contains configuration settings for a client's pipeline.
type ResourceID ¶
type ResourceID struct { // Parent is the parent ResourceID of this instance. // Can be nil if there is no parent. Parent *ResourceID // SubscriptionID is the subscription ID in this resource ID. // The value can be empty if the resource ID does not contain a subscription ID. SubscriptionID string // ResourceGroupName is the resource group name in this resource ID. // The value can be empty if the resource ID does not contain a resource group name. ResourceGroupName string // Provider represents the provider name in this resource ID. // This is only valid when the resource ID represents a resource provider. // Example: `/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Insights` Provider string // Location is the location in this resource ID. // The value can be empty if the resource ID does not contain a location name. Location string // ResourceType represents the type of this resource ID. ResourceType ResourceType // Name is the resource name of this resource ID. Name string // contains filtered or unexported fields }
ResourceID represents a resource ID such as `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRg`. Don't create this type directly, use ParseResourceID instead.
func ParseResourceID ¶
func ParseResourceID(id string) (*ResourceID, error)
ParseResourceID parses a string to an instance of ResourceID
Code:
Output:Example¶
{
rawResourceID := "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRg/providers/Microsoft.Network/virtualNetworks/vnet/subsets/mySub"
id, err := ParseResourceID(rawResourceID)
if err != nil {
panic(err)
}
fmt.Printf("ID: %s\n", id.String())
fmt.Printf("Name: %s, ResourceType: %s, SubscriptionId: %s, ResourceGroupName: %s\n",
id.Name, id.ResourceType, id.SubscriptionID, id.ResourceGroupName)
fmt.Printf("Parent: %s\n", id.Parent.String())
fmt.Printf("Name: %s, ResourceType: %s, SubscriptionId: %s, ResourceGroupName: %s\n",
id.Parent.Name, id.Parent.ResourceType, id.Parent.SubscriptionID, id.Parent.ResourceGroupName)
fmt.Printf("Parent: %s\n", id.Parent.Parent.String())
fmt.Printf("Name: %s, ResourceType: %s, SubscriptionId: %s, ResourceGroupName: %s\n",
id.Parent.Parent.Name, id.Parent.Parent.ResourceType, id.Parent.Parent.SubscriptionID, id.Parent.Parent.ResourceGroupName)
fmt.Printf("Parent: %s\n", id.Parent.Parent.Parent.String())
fmt.Printf("Name: %s, ResourceType: %s, SubscriptionId: %s, ResourceGroupName: %s\n",
id.Parent.Parent.Parent.Name, id.Parent.Parent.Parent.ResourceType, id.Parent.Parent.Parent.SubscriptionID, id.Parent.Parent.Parent.ResourceGroupName)
// Output:
// ID: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRg/providers/Microsoft.Network/virtualNetworks/vnet/subsets/mySub
// Name: mySub, ResourceType: Microsoft.Network/virtualNetworks/subsets, SubscriptionId: 00000000-0000-0000-0000-000000000000, ResourceGroupName: myRg
// Parent: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRg/providers/Microsoft.Network/virtualNetworks/vnet
// Name: vnet, ResourceType: Microsoft.Network/virtualNetworks, SubscriptionId: 00000000-0000-0000-0000-000000000000, ResourceGroupName: myRg
// Parent: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRg
// Name: myRg, ResourceType: Microsoft.Resources/resourceGroups, SubscriptionId: 00000000-0000-0000-0000-000000000000, ResourceGroupName: myRg
// Parent: /subscriptions/00000000-0000-0000-0000-000000000000
// Name: 00000000-0000-0000-0000-000000000000, ResourceType: Microsoft.Resources/subscriptions, SubscriptionId: 00000000-0000-0000-0000-000000000000, ResourceGroupName:
}
ID: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRg/providers/Microsoft.Network/virtualNetworks/vnet/subsets/mySub
Name: mySub, ResourceType: Microsoft.Network/virtualNetworks/subsets, SubscriptionId: 00000000-0000-0000-0000-000000000000, ResourceGroupName: myRg
Parent: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRg/providers/Microsoft.Network/virtualNetworks/vnet
Name: vnet, ResourceType: Microsoft.Network/virtualNetworks, SubscriptionId: 00000000-0000-0000-0000-000000000000, ResourceGroupName: myRg
Parent: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRg
Name: myRg, ResourceType: Microsoft.Resources/resourceGroups, SubscriptionId: 00000000-0000-0000-0000-000000000000, ResourceGroupName: myRg
Parent: /subscriptions/00000000-0000-0000-0000-000000000000
Name: 00000000-0000-0000-0000-000000000000, ResourceType: Microsoft.Resources/subscriptions, SubscriptionId: 00000000-0000-0000-0000-000000000000, ResourceGroupName:
func (*ResourceID) String ¶
func (id *ResourceID) String() string
String returns the string of the ResourceID
type ResourceType ¶
type ResourceType struct { // Namespace is the namespace of the resource type. // e.g. "Microsoft.Network" in resource type "Microsoft.Network/virtualNetworks/subnets" Namespace string // Type is the full type name of the resource type. // e.g. "virtualNetworks/subnets" in resource type "Microsoft.Network/virtualNetworks/subnets" Type string // Types is the slice of all the sub-types of this resource type. // e.g. ["virtualNetworks", "subnets"] in resource type "Microsoft.Network/virtualNetworks/subnets" Types []string // contains filtered or unexported fields }
ResourceType represents an Azure resource type, e.g. "Microsoft.Network/virtualNetworks/subnets". Don't create this type directly, use ParseResourceType or NewResourceType instead.
func NewResourceType ¶
func NewResourceType(providerNamespace, typeName string) ResourceType
NewResourceType creates an instance of ResourceType using a provider namespace such as "Microsoft.Network" and type such as "virtualNetworks/subnets".
func ParseResourceType ¶
func ParseResourceType(resourceIDOrType string) (ResourceType, error)
ParseResourceType parses the ResourceType from a resource type string (e.g. Microsoft.Network/virtualNetworks/subsets)
or a resource identifier string.
e.g. /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRg/providers/Microsoft.Network/virtualNetworks/vnet/subnets/mySubnet)
Code:
Output: Code:
Output:Example¶
{
rawResourceType := "Microsoft.Network/virtualNetworks/subnets"
resourceType, err := ParseResourceType(rawResourceType)
if err != nil {
panic(err)
}
fmt.Printf("ResourceType: %s\n", resourceType.String())
fmt.Printf("Namespace: %s, Type: %s\n", resourceType.Namespace, resourceType.Type)
// Output:
// ResourceType: Microsoft.Network/virtualNetworks/subnets
// Namespace: Microsoft.Network, Type: virtualNetworks/subnets
}
ResourceType: Microsoft.Network/virtualNetworks/subnets
Namespace: Microsoft.Network, Type: virtualNetworks/subnets
Example (FromResourceID)¶
{
rawResourceID := "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRg/providers/Microsoft.Network/virtualNetworks/vnet/subnets/mySub"
resourceType, err := ParseResourceType(rawResourceID)
if err != nil {
panic(err)
}
fmt.Printf("ResourceType: %s\n", resourceType.String())
fmt.Printf("Namespace: %s, Type: %s\n", resourceType.Namespace, resourceType.Type)
// Output:
// ResourceType: Microsoft.Network/virtualNetworks/subnets
// Namespace: Microsoft.Network, Type: virtualNetworks/subnets
}
ResourceType: Microsoft.Network/virtualNetworks/subnets
Namespace: Microsoft.Network, Type: virtualNetworks/subnets
func (ResourceType) AppendChild ¶
func (t ResourceType) AppendChild(childType string) ResourceType
AppendChild creates an instance of ResourceType using the receiver as the parent with childType appended to it.
func (ResourceType) IsParentOf ¶
func (t ResourceType) IsParentOf(child ResourceType) bool
IsParentOf returns true when the receiver is the parent resource type of the child.
func (ResourceType) String ¶
func (t ResourceType) String() string
String returns the string of the ResourceType
Source Files ¶
arm.go client_options.go doc.go resource_identifier.go resource_type.go
Directories ¶
Path | Synopsis |
---|---|
arm/internal | |
arm/policy | |
arm/runtime |
- Version
- v0.23.1
- Published
- Apr 14, 2022
- Platform
- darwin/amd64
- Imports
- 4 packages
- Last checked
- 58 minutes ago –
Tools for package owners.