armclient

package
v1.2.132559162 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAPIVersion

func GetAPIVersion(armType string) (string, error)

GetAPIVersion returns the most recent API version for a resource

func GetSubscriptionIDFromResourceID added in v1.2.132559162

func GetSubscriptionIDFromResourceID(resourceID string) string

GetSubscriptionIDFromResourceID returns the subscription ID from a resource ID Returns empty string on no match

Types

type AzCLIToken added in v1.1.170

type AzCLIToken struct {
	AccessToken  string `json:"accessToken"`
	TokenType    string `json:"tokenType"`
	Tenant       string `json:"tenant"`
	Subscription string `json:"subscription"`
}

AzCLIToken contains token info from az cli

func AcquireTokenForResourceFromAzCLI added in v1.2.104948434

func AcquireTokenForResourceFromAzCLI(subscription string, resource string) (AzCLIToken, error)

AcquireTokenForResourceFromAzCLI gets a token for the specified resource endpoint

type Client added in v1.1.394

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

Client is used to talk to the ARM API's in Azure

var LegacyInstance *Client

LegacyInstance is a singleton ARMClient used while migrating to the injected client

func NewClientFromCLI added in v1.1.394

func NewClientFromCLI(tenantID string, responseProcessors ...ResponseProcessor) *Client

NewClientFromCLI creates a new client using the auth details on disk used by the azurecli

func NewClientFromConfig added in v1.2.84840979

func NewClientFromConfig(client *http.Client, tokenFunc TokenFunc, reqPerSecLimit float64, responseProcessors ...ResponseProcessor) *Client

NewClientFromConfig create a client for testing using custom token func and httpclient

func (*Client) DoRawRequest added in v1.2.771

func (c *Client) DoRawRequest(ctx context.Context, req *http.Request) (*http.Response, error)

DoRawRequest makes a raw request with ARM authentication headers set

func (*Client) DoRequest added in v1.1.394

func (c *Client) DoRequest(ctx context.Context, method, path string) (string, error)

DoRequest makes an ARM rest request

func (*Client) DoRequestAsync added in v1.1.394

func (c *Client) DoRequestAsync(ctx context.Context, method, path string) chan RequestResult

DoRequestAsync makes an ARM rest request

func (*Client) DoRequestWithBody added in v1.1.394

func (c *Client) DoRequestWithBody(ctx context.Context, method, path, body string) (string, error)

DoRequestWithBody makes an ARM rest request

func (*Client) DoResourceGraphQuery added in v1.1.394

func (c *Client) DoResourceGraphQuery(ctx context.Context, subscription, query string) (string, error)

DoResourceGraphQuery performs an azure graph query

func (*Client) GetTenantID added in v1.1.394

func (c *Client) GetTenantID() string

GetTenantID gets the current tenandid from AzCli

func (*Client) GetToken added in v1.1.394

func (c *Client) GetToken() (AzCLIToken, error)

GetToken gets the cached cli token

func (*Client) PopulateResourceAPILookup added in v1.1.394

func (c *Client) PopulateResourceAPILookup(ctx context.Context)

PopulateResourceAPILookup is used to build a cache of resourcetypes -> api versions this is needed when requesting details from a resource as APIVersion isn't known and is required

func (*Client) SetAquireToken added in v1.1.394

func (c *Client) SetAquireToken(aquireFunc func(clearCache bool) (AzCLIToken, error))

SetAquireToken lets you override the token func for testing or other purposes

func (*Client) SetClient added in v1.1.394

func (c *Client) SetClient(newClient *http.Client)

SetClient is used to override the HTTP Client used. This is useful when testing

type MetricNamespaceResponse added in v1.1.263

type MetricNamespaceResponse struct {
	Value []struct {
		ID             string `json:"id"`
		Name           string `json:"name"`
		Type           string `json:"type"`
		Classification string `json:"classification"`
		Properties     struct {
			MetricNamespaceName string `json:"metricNamespaceName"`
		} `json:"properties"`
	} `json:"value"`
}

MetricNamespaceResponse https://docs.microsoft.com/en-us/rest/api/monitor/metricnamespaces/list

type MetricResponse added in v1.1.263

type MetricResponse struct {
	Cost           int    `json:"cost"`
	Timespan       string `json:"timespan"`
	Interval       string `json:"interval"`
	Namespace      string `json:"namespace"`
	Resourceregion string `json:"resourceregion"`
	Value          []struct {
		ID   string `json:"id"`
		Type string `json:"type"`
		Name struct {
			Value          string `json:"value"`
			LocalizedValue string `json:"localizedValue"`
		} `json:"name"`
		Unit       string `json:"unit"`
		Timeseries []struct {
			Metadatavalues []struct {
				Name struct {
					Value          string `json:"value"`
					LocalizedValue string `json:"localizedValue"`
				} `json:"name"`
				Value string `json:"value"`
			} `json:"metadatavalues"`
			Data []map[string]interface{} `json:"data"`
		} `json:"timeseries"`
	} `json:"value"`
}

MetricResponse https://docs.microsoft.com/en-us/rest/api/monitor/metrics/list

type MetricsListResponse added in v1.1.263

type MetricsListResponse struct {
	Value []struct {
		ID         string `json:"id"`
		ResourceID string `json:"resourceId"`
		Namespace  string `json:"namespace"`
		Name       struct {
			Value          string `json:"value"`
			LocalizedValue string `json:"localizedValue"`
		} `json:"name"`
		IsDimensionRequired       bool     `json:"isDimensionRequired"`
		Unit                      string   `json:"unit"`
		PrimaryAggregationType    string   `json:"primaryAggregationType"`
		SupportedAggregationTypes []string `json:"supportedAggregationTypes"`
		MetricAvailabilities      []struct {
			TimeGrain string `json:"timeGrain"`
			Retention string `json:"retention"`
		} `json:"metricAvailabilities"`
		Dimensions []struct {
			Value          string `json:"value"`
			LocalizedValue string `json:"localizedValue"`
		} `json:"dimensions"`
	} `json:"value"`
}

MetricsListResponse https://docs.microsoft.com/en-us/rest/api/monitor/metricdefinitions/list

type ProvidersResponse

type ProvidersResponse struct {
	Providers []struct {
		ID            string `json:"id"`
		Namespace     string `json:"namespace"`
		Authorization struct {
			ApplicationID    string `json:"applicationId"`
			RoleDefinitionID string `json:"roleDefinitionId"`
		} `json:"authorization,omitempty"`
		ResourceTypes []struct {
			ResourceType string        `json:"resourceType"`
			Locations    []interface{} `json:"locations"`
			APIVersions  []string      `json:"apiVersions"`
		} `json:"resourceTypes"`
		RegistrationState string `json:"registrationState"`
		Authorizations    []struct {
			ApplicationID    string `json:"applicationId"`
			RoleDefinitionID string `json:"roleDefinitionId"`
		} `json:"authorizations,omitempty"`
	} `json:"value"`
}

ProvidersResponse providers list rest type

type RequestResult

type RequestResult struct {
	Result string
	Error  error
}

RequestResult used with async channel

type Resource

type Resource struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
	Sku  struct {
		Name string `json:"name"`
		Tier string `json:"tier"`
	} `json:"sku"`
	Kind       string `json:"kind"`
	Location   string `json:"location"`
	Properties struct {
		ProvisioningState string `json:"provisioningState"`
	} `json:"properties"`
}

Resource is a resource in azure

type ResourceResponse

type ResourceResponse struct {
	Resources []Resource `json:"value"`
}

ResourceResponse Resources list rest type

type ResponseProcessor added in v1.2.771

type ResponseProcessor func(requestPath string, response *http.Response, responseBody string)

ResponseProcessor can be used to handle additional actions once a response is received

type TokenFunc added in v1.1.394

type TokenFunc func(clearCache bool) (AzCLIToken, error)

TokenFunc is the interface to meet for functions which retrieve tokens for the ARMClient

Jump to

Keyboard shortcuts

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