package arm

import "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"

Package arm contains functionality specific to Azure Resource Manager clients.

Index

Examples

Variables

var (
	// SubscriptionResourceType is the ResourceType of a subscription
	SubscriptionResourceType = NewResourceType(builtInResourceNamespace, "subscriptions")

	// ResourceGroupResourceType is the ResourceType of a resource group
	ResourceGroupResourceType = NewResourceType(builtInResourceNamespace, "resourceGroups")

	// TenantResourceType is the ResourceType of a tenant
	TenantResourceType = NewResourceType(builtInResourceNamespace, "tenants")

	// ProviderResourceType is the ResourceType of a provider
	ProviderResourceType = NewResourceType(builtInResourceNamespace, "providers")
)
var (
	// RootResourceID defines the tenant as the root parent of all other ResourceID.
	RootResourceID = &ResourceID{
		Parent:       nil,
		ResourceType: TenantResourceType,
		Name:         "",
	}
)

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

	// Endpoint is the base URL for Azure Resource Manager. Defaults to AzurePublicCloud.
	Endpoint Endpoint
}

ClientOptions contains configuration settings for a client's pipeline.

type Endpoint

type Endpoint string

Endpoint is the base URL for Azure Resource Manager.

const (
	// AzureChina is the Azure Resource Manager China cloud endpoint.
	AzureChina Endpoint = "https://management.chinacloudapi.cn/"
	// AzureGovernment is the Azure Resource Manager US government cloud endpoint.
	AzureGovernment Endpoint = "https://management.usgovcloudapi.net/"
	// AzurePublicCloud is the Azure Resource Manager public cloud endpoint.
	AzurePublicCloud Endpoint = "https://management.azure.com/"
)

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

Example

Code:

{
	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:
}

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:

func (*ResourceID) String

func (id *ResourceID) String() string

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)

Example

Code:

{
	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
}

Output:

ResourceType: Microsoft.Network/virtualNetworks/subnets
Namespace: Microsoft.Network, Type: virtualNetworks/subnets
Example (FromResourceID)

Code:

{
	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
}

Output:

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

Source Files

client_options.go doc.go resource_identifier.go resource_type.go

Directories

PathSynopsis
arm/internal
arm/policy
arm/runtime
Version
v0.21.1
Published
Feb 4, 2022
Platform
js/wasm
Imports
3 packages
Last checked
52 minutes ago

Tools for package owners.