clientv2

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultBaseURI is the default base URI for the client.
	DefaultBaseURI = "https://management.azure.com"

	// ModuleName is used for telemetry if needed.
	ModuleName = "radius"

	// ModuleVersion is used for telemetry if needed.
	ModuleVersion = "public-preview"
)

Variables

View Source
var (
	AccountsClientAPIVersion       = "2023-10-01"
	StateStoreClientAPIVersion     = "2023-10-01"
	ServiceBusClientAPIVersion     = "2023-10-01-preview"
	MSIClientAPIVersion            = "2023-10-01-preview"
	RoleAssignmentClientAPIVersion = "2022-04-01"

	// https://github.com/Azure/azure-rest-api-specs/blob/main/specification/sql/resource-manager/readme.md
	SQLManagementClientAPIVersion = "2021-11-01"

	// https://github.com/Azure/azure-rest-api-specs/blob/main/specification/redis/resource-manager/readme.md
	RedisManagementClientAPIVersion = "2022-06-01"

	// https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cosmos-db/resource-manager/readme.md
	DocumentDBManagementClientAPIVersion = "2022-08-15"
)

Functions

func ExtractResponseError

func ExtractResponseError(err error) (*azcore.ResponseError, bool)

ExtractResponseError extracts the ResponseError from the error. Returns true if the error is a ResponseError.

func GetResourceGroupLocation

func GetResourceGroupLocation(ctx context.Context, subscriptionID string, resourceGroupName string, options *Options) (*string, error)

GetResourceGroupLocation retrieves the location of a given resource group from an Azure subscription. It returns an error if the resource group or the subscription cannot be found.

func Is404Error

func Is404Error(err error) bool

Is404Error returns true if the error is a 404 payload from an autorest operation.

func NewAccountsClient

func NewAccountsClient(subscriptionID string, options *Options) (*armstorage.AccountsClient, error)

NewAccountsClient creates a new ARM Storage Accounts Client with the given subscription ID and options.

func NewDeploymentOperationsClient

func NewDeploymentOperationsClient(subscriptionID string, options *Options) (*armresources.DeploymentOperationsClient, error)

NewDeploymentOperationsClient creates a new ARM deployment operations client for managing deployment operations.

func NewDeploymentsClient

func NewDeploymentsClient(subscriptionID string, options *Options) (*armresources.DeploymentsClient, error)

// NewDeploymentsClient creates a new DeploymentsClient which can be used to manage Azure deployments.

func NewFederatedIdentityClient

func NewFederatedIdentityClient(subscriptionID string, options *Options) (*armmsi.FederatedIdentityCredentialsClient, error)

NewFederatedIdentityClient creates a new FederatedIdentityCredentialsClient and returns it along with any error.

func NewGenericResourceClient

func NewGenericResourceClient(subscriptionID string, options *Options, clientOptions *arm.ClientOptions) (*armresources.Client, error)

NewGenericResourceClient creates a new ARM resources client with the given subscription ID, options and client options.

func NewProvidersClient

func NewProvidersClient(subcriptionID string, options *Options, clientOptions *arm.ClientOptions) (*armresources.ProvidersClient, error)

NewProvidersClient creates a new ARM ProvidersClient with the given subscription ID and ARM ClientOptions, that can be used to look up resource providers and API versions.

func NewResourceGroupsClient

func NewResourceGroupsClient(subscriptionID string, options *Options) (*armresources.ResourceGroupsClient, error)

NewResourceGroupsClient creates a new ARM Resource Groups Client with the given subscription ID and options.

func NewRoleAssignmentsClient

func NewRoleAssignmentsClient(subscriptionID string, options *Options) (*armauthorization.RoleAssignmentsClient, error)

NewRoleAssignmentsClient creates a new RoleAssignmentsClient with the given subscriptionID and Options, and returns an error if one occurs.

func NewRoleDefinitionsClient

func NewRoleDefinitionsClient(options *Options) (*armauthorization.RoleDefinitionsClient, error)

NewRoleDefinitionsClient creates a new RoleDefinitionsClient from the given Options and returns it, or an error if one occurs.

func NewServiceBusNamespacesClient

func NewServiceBusNamespacesClient(subscriptionID string, options *Options) (*armservicebus.NamespacesClient, error)

NewServiceBusNamespacesClient creates a new ARM Service Bus Namespaces Client with the given subscription ID and options.

func NewSubscriptionsClient

func NewSubscriptionsClient(options *Options) (*armsubscriptions.Client, error)

NewSubscriptionsClient creates a new ARM Subscriptions Client using the provided options and returns it, or an error if one occurs.

func NewUserAssignedIdentityClient

func NewUserAssignedIdentityClient(subscriptionID string, options *Options) (*armmsi.UserAssignedIdentitiesClient, error)

NewUserAssignedIdentityClient creates a new UserAssignedIdentitiesClient with the given subscriptionID and Options and returns it, or an error if one occurs.

func TryUnfoldErrorResponse

func TryUnfoldErrorResponse(err error) *generated.ErrorDetail

TryUnfoldErrorResponse takes an error that wrapped a radclient.ErrorResponse and unfold nested JSON messages into structured radclient.ErrorDetail field.

If the given error isn't wrapping a *radclient.ErrorResponse, nil is returned.

func TryUnfoldResponseError

func TryUnfoldResponseError(err error) *v1.ErrorDetails

TryUnfoldResponseError attempts to convert a ResponseError into an ErrorDetails object.

func UnfoldErrorDetails

func UnfoldErrorDetails(d *generated.ErrorDetail) generated.ErrorDetail

UnfoldErrorDetails extract the Message field of a given *radclient.ErrorDetail into its correspoding Details field, which is structured.

Types

type ClientCustomActionResponse

type ClientCustomActionResponse struct {
	// Body is the Custom Action response body.
	Body map[string]any
}

ClientCustomActionResponse is the response we get from invoking a custom action.

type CustomActionClient

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

CustomActionClient is the client to invoke custom actions on Azure resources. Ex: listSecrets on a MongoDatabase.

func NewCustomActionClient

func NewCustomActionClient(subscriptionID string, options *Options, clientOptions *arm.ClientOptions) (*CustomActionClient, error)

NewCustomActionClient creates a new CustomActionClient with the provided subscriptionID and Options, and returns an error if one occurs.

func (*CustomActionClient) InvokeCustomAction

func (client *CustomActionClient) InvokeCustomAction(ctx context.Context, resourceID, apiVersion, action string) (*ClientCustomActionResponse, error)

InvokeCustomAction sends a request to the server to invoke a custom action on the given resource and returns the response body and an error if one occurs.

type Options

type Options struct {
	// Cred represents a credential for OAuth token.
	Cred azcore.TokenCredential

	// BaseURI represents the base URI for the client.
	BaseURI string
}

Options represents the client option for azure sdk client including authentication.

type ServiceError

type ServiceError struct {
	Code           string                   `json:"code,omitempty" yaml:"code,omitempty"`
	Message        string                   `json:"message,omitempty" yaml:"message,omitempty"`
	Target         *string                  `json:"target,omitempty" yaml:"target,omitempty"`
	Details        []*generated.ErrorDetail `json:"details,omitempty" yaml:"details,omitempty"`
	InnerError     map[string]any           `json:"innererror,omitempty" yaml:"innererror,omitempty"`
	AdditionalInfo []map[string]any         `json:"additionalInfo,omitempty" yaml:"additionalInfo,omitempty"`
}

ServiceError conforms to the OData v4 error format. See http://docs.oasis-open.org/odata/odata-json-format/v4.0/os/odata-json-format-v4.0-os.html

Note that this type is almost the same to that of azure.ServiceError, with the difference being the Details field having more structure. We need that structure to unfold the error messages.

func UnfoldServiceError

func UnfoldServiceError(in *generated.ErrorDetail) *ServiceError

UnfoldServiceError unfolds the Details field in the given azure.ServiceError, and convert messages which are raw JSON of an radclient.ErrorResponse into structured radclient.ErrorDetails fields.

This is needed because for custom RP, errors are not treated as structured JSON, even if we follow the error format from ARM.

type WrappedErrorResponse

type WrappedErrorResponse struct {
	ErrorResponse generated.ErrorResponse
}

func (WrappedErrorResponse) Error

func (w WrappedErrorResponse) Error() string

Error returns the error message from the ErrorResponse struct.

Jump to

Keyboard shortcuts

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