...

Package management

import "github.com/Azure/azure-sdk-for-go/services/classic/management"
Overview
Index
Subdirectories

Overview ▾

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

Constants

const (
    DefaultAzureManagementURL    = "https://management.core.windows.net"
    DefaultOperationPollInterval = time.Second * 30
    DefaultAPIVersion            = "2014-10-01"
)

Variables

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

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.

type AzureError

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

type AzureError struct {
    Code    string
    Message string
}

func (AzureError) Error

func (e AzureError) Error() string

Error implements the error interface for the AzureError type.

type Client

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

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
}

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

ClientConfig provides a configuration for use by a Client.

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

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

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 GetOperationStatusResponse struct {
    XMLName        xml.Name `xml:"http://schemas.microsoft.com/windowsazure Operation"`
    ID             string
    Status         OperationStatus
    HTTPStatusCode string
    Error          *AzureError
}

type OperationID

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

type OperationID string

type OperationStatus

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

type OperationStatus string

List of states an operation can be reported as

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

Subdirectories

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