management

package
v8.0.1-beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

README

Azure Service Management packages for Go

The github.com/Azure/azure-sdk-for-go/management packages are used to perform operations using the Azure Service Management (ASM), aka classic deployment model. Read more about Azure Resource Manager vs. classic deployment. Packages for Azure Resource Manager are in the arm folder.

First a Sidenote: Authentication and the Azure Service Manager

The client currently supports authentication to the Service Management API with certificates or Azure .publishSettings file. You can download the .publishSettings file for your subscriptions here.

Example: Creating a Linux Virtual Machine

Complete source code for this example can be found in example.go.To try this example, download your .publishSettings and add its path in the first line of the main function. Run the example with commands:

$ cd management/examples
$ go run example.go

Documentation

Overview

Package management provides the main API client to construct other clients and make requests to the Microsoft Azure Service Management REST API.

Index

Constants

View Source
const (
	DefaultAzureManagementURL    = "https://management.core.windows.net"
	DefaultOperationPollInterval = time.Second * 30
	DefaultAPIVersion            = "2014-10-01"
	DefaultUserAgent             = "azure-sdk-for-go"
)

Variables

View Source
var (
	// ErrOperationCancelled from WaitForOperation when the polling loop is
	// cancelled through signaling the channel.
	ErrOperationCancelled = errors.New("Polling for operation status cancelled")
)

Functions

func IsResourceNotFoundError

func IsResourceNotFoundError(err error) bool

IsResourceNotFoundError returns true if the provided error is an AzureError reporting that a given resource has not been found.

Types

type AzureError

type AzureError struct {
	Code    string
	Message string
}

AzureError represents an error returned by the management API. It has an error code (for example, ResourceNotFound) and a descriptive message.

func (AzureError) Error

func (e AzureError) Error() string

Error implements the error interface for the AzureError type.

type Client

type Client interface {
	// SendAzureGetRequest sends a request to the management API using the HTTP GET method
	// and returns the response body or an error.
	SendAzureGetRequest(url string) ([]byte, error)

	// SendAzurePostRequest sends a request to the management API using the HTTP POST method
	// and returns the request ID or an error.
	SendAzurePostRequest(url string, data []byte) (OperationID, error)

	// SendAzurePostRequestWithReturnedResponse sends a request to the management API using
	// the HTTP POST method and returns the response body or an error.
	SendAzurePostRequestWithReturnedResponse(url string, data []byte) ([]byte, error)

	// SendAzurePutRequest sends a request to the management API using the HTTP PUT method
	// and returns the request ID or an error. The content type can be specified, however
	// if an empty string is passed, the default of "application/xml" will be used.
	SendAzurePutRequest(url, contentType string, data []byte) (OperationID, error)

	// SendAzureDeleteRequest sends a request to the management API using the HTTP DELETE method
	// and returns the request ID or an error.
	SendAzureDeleteRequest(url string) (OperationID, error)

	// GetOperationStatus gets the status of operation with given Operation ID.
	// WaitForOperation utility method can be used for polling for operation status.
	GetOperationStatus(operationID OperationID) (GetOperationStatusResponse, error)

	// WaitForOperation polls the Azure API for given operation ID indefinitely
	// until the operation is completed with either success or failure.
	// It is meant to be used for waiting for the result of the methods that
	// return an OperationID value (meaning a long running operation has started).
	//
	// Cancellation of the polling loop (for instance, timing out) is done through
	// cancel channel. If the user does not want to cancel, a nil chan can be provided.
	// To cancel the method, it is recommended to close the channel provided to this
	// method.
	//
	// If the operation was not successful or cancelling is signaled, an error
	// is returned.
	WaitForOperation(operationID OperationID, cancel chan struct{}) error
}

Client is the base Azure Service Management API client instance that can be used to construct client instances for various services.

func ClientFromPublishSettingsData

func ClientFromPublishSettingsData(settingsData []byte, subscriptionID string) (client Client, err error)

ClientFromPublishSettingsData unmarshalls the contents of a publish settings file from https://manage.windowsazure.com/publishsettings. If subscriptionID is left empty, the first subscription in the file is used.

func ClientFromPublishSettingsDataWithConfig

func ClientFromPublishSettingsDataWithConfig(data []byte, subscriptionID string, config ClientConfig) (client Client, err error)

ClientFromPublishSettingsDataWithConfig unmarshalls the contents of a publish settings file from https://manage.windowsazure.com/publishsettings. If subscriptionID is left empty, the first subscription in the string is used.

func ClientFromPublishSettingsFile

func ClientFromPublishSettingsFile(filePath, subscriptionID string) (client Client, err error)

ClientFromPublishSettingsFile reads a publish settings file downloaded from https://manage.windowsazure.com/publishsettings. If subscriptionID is left empty, the first subscription in the file is used.

func ClientFromPublishSettingsFileWithConfig

func ClientFromPublishSettingsFileWithConfig(filePath, subscriptionID string, config ClientConfig) (client Client, err error)

ClientFromPublishSettingsFileWithConfig reads a publish settings file downloaded from https://manage.windowsazure.com/publishsettings. If subscriptionID is left empty, the first subscription in the file is used.

func NewAnonymousClient

func NewAnonymousClient() Client

NewAnonymousClient creates a new azure.Client with no credentials set.

func NewClient

func NewClient(subscriptionID string, managementCert []byte) (Client, error)

NewClient creates a new Client using the given subscription ID and management certificate.

func NewClientFromConfig

func NewClientFromConfig(subscriptionID string, managementCert []byte, config ClientConfig) (Client, error)

NewClientFromConfig creates a new Client using a given ClientConfig.

type ClientConfig

type ClientConfig struct {
	ManagementURL         string
	OperationPollInterval time.Duration
	UserAgent             string
	APIVersion            string
}

ClientConfig provides a configuration for use by a Client.

func DefaultConfig

func DefaultConfig() ClientConfig

DefaultConfig returns the default client configuration used to construct a client. This value can be used to make modifications on the default API configuration.

type GetOperationStatusResponse

type GetOperationStatusResponse struct {
	XMLName        xml.Name `xml:"http://schemas.microsoft.com/windowsazure Operation"`
	ID             string
	Status         OperationStatus
	HTTPStatusCode string
	Error          *AzureError
}

GetOperationStatusResponse represents an in-flight operation. Use client.GetOperationStatus() to get the operation given the operation ID, or use WaitForOperation() to poll and wait until the operation has completed. See https://msdn.microsoft.com/en-us/library/azure/ee460783.aspx

type OperationID

type OperationID string

OperationID is assigned by Azure API and can be used to look up the status of an operation

type OperationStatus

type OperationStatus string

OperationStatus describes the states an Microsoft Azure Service Management operation an be in.

const (
	OperationStatusInProgress OperationStatus = "InProgress"
	OperationStatusSucceeded  OperationStatus = "Succeeded"
	OperationStatusFailed     OperationStatus = "Failed"
)

List of states an operation can be reported as

Directories

Path Synopsis
Package hostedservice provides a client for Hosted Services.
Package hostedservice provides a client for Hosted Services.
Package location provides a client for Locations.
Package location provides a client for Locations.
Package networksecuritygroup provides a client for Network Security Groups.
Package networksecuritygroup provides a client for Network Security Groups.
Package osimage provides a client for Operating System Images.
Package osimage provides a client for Operating System Images.
Package storageservice provides a client for Storage Services.
Package storageservice provides a client for Storage Services.
Package testutils contains some test utilities for the Azure SDK
Package testutils contains some test utilities for the Azure SDK
Package virtualmachine provides a client for Virtual Machines.
Package virtualmachine provides a client for Virtual Machines.
Package virtualmachinedisk provides a client for Virtual Machine Disks.
Package virtualmachinedisk provides a client for Virtual Machine Disks.
Package virtualmachineimage provides a client for Virtual Machine Images.
Package virtualmachineimage provides a client for Virtual Machine Images.
Package virtualnetwork provides a client for Virtual Networks.
Package virtualnetwork provides a client for Virtual Networks.
Package vmutils provides convenience methods for creating Virtual Machine Role configurations.
Package vmutils provides convenience methods for creating Virtual Machine Role configurations.

Jump to

Keyboard shortcuts

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