arm

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 9 Imported by: 720

Documentation

Overview

Package arm contains functionality specific to Azure Resource Manager clients.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ProviderResourceType = NewResourceType(builtInResourceNamespace, "providers")

ProviderResourceType is the ResourceType of a provider

View Source
var ResourceGroupResourceType = NewResourceType(builtInResourceNamespace, "resourceGroups")

ResourceGroupResourceType is the ResourceType of a resource group

View Source
var RootResourceID = &ResourceID{
	Parent:       nil,
	ResourceType: TenantResourceType,
	Name:         "",
}

RootResourceID defines the tenant as the root parent of all other ResourceID.

View Source
var SubscriptionResourceType = NewResourceType(builtInResourceNamespace, "subscriptions")

SubscriptionResourceType is the ResourceType of a subscription

View Source
var TenantResourceType = NewResourceType(builtInResourceNamespace, "tenants")

TenantResourceType is the ResourceType of a tenant

Functions

This section is empty.

Types

type Client added in v1.3.0

type Client struct {
	// contains filtered or unexported fields
}

Client is a HTTP client for use with ARM endpoints. It consists of an endpoint, pipeline, and tracing provider.

func NewClient added in v1.3.0

func NewClient(clientName, moduleVersion string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error)

NewClient creates a new Client instance with the provided values. This client is intended to be used with Azure Resource Manager endpoints.

  • clientName - the fully qualified name of the client ("package.Client"); this is used by the tracing provider when creating spans
  • moduleVersion - the version of the containing module; used by the telemetry policy
  • cred - the TokenCredential used to authenticate the request
  • options - optional client configurations; pass nil to accept the default values

func (*Client) Endpoint added in v1.3.0

func (c *Client) Endpoint() string

Endpoint returns the service's base URL for this client.

func (*Client) Pipeline added in v1.3.0

func (c *Client) Pipeline() runtime.Pipeline

Pipeline returns the pipeline for this client.

func (*Client) Tracer added in v1.3.0

func (c *Client) Tracer() tracing.Tracer

Tracer returns the tracer for this client.

type ClientOptions added in v0.20.0

type ClientOptions = armpolicy.ClientOptions

ClientOptions contains configuration settings for a client's pipeline.

type ResourceID added in v0.21.0

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 added in v0.21.0

func ParseResourceID(id string) (*ResourceID, error)

ParseResourceID parses a string to an instance of ResourceID

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:

func (*ResourceID) String added in v0.21.0

func (id *ResourceID) String() string

String returns the string of the ResourceID

type ResourceType added in v0.21.0

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 added in v0.21.0

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 added in v0.21.0

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

func (ResourceType) AppendChild added in v0.21.0

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 added in v0.21.0

func (t ResourceType) IsParentOf(child ResourceType) bool

IsParentOf returns true when the receiver is the parent resource type of the child.

func (ResourceType) String added in v0.21.0

func (t ResourceType) String() string

String returns the string of the ResourceType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL