Back to godoc.org
github.com/Azure/azure-sdk-for-go / services / classic / management

package management

v44.0.0+incompatible
Latest Go to latest
Published: Jul 2, 2020 | License: Apache-2.0 | Module: github.com/Azure/azure-sdk-for-go

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

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

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

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier