Documentation
¶
Index ¶
- Constants
- func DetectTLE(data []byte) (bool, error)
- func IsTLE(s string) bool
- func ListProvisioningStates() iter.Seq[ProvisioningState]
- func ListSubscriptionStates() iter.Seq[SubscriptionState]
- func MarshalJSON(v any) ([]byte, error)
- func UnmarshalDeploymentPreflight(data []byte) (*DeploymentPreflight, *CloudError)
- func WriteCloudError(w http.ResponseWriter, err *CloudError)
- func WriteConflictError(w http.ResponseWriter, resourceID *azcorearm.ResourceID, format string, ...)
- func WriteDeploymentPreflightResponse(w http.ResponseWriter, preflightErrors []CloudErrorBody)
- func WriteError(w http.ResponseWriter, statusCode int, code, target, format string, ...)
- func WriteInternalServerError(w http.ResponseWriter)
- func WriteInvalidRequestContentError(w http.ResponseWriter, err error)
- func WriteJSONResponse(writer http.ResponseWriter, statusCode int, body any) (int, error)
- func WriteResourceNotFoundError(w http.ResponseWriter, resourceID *azcorearm.ResourceID)
- type AccountOwner
- type AvailabilityZone
- type CloudError
- func NewCloudError(statusCode int, code, target, format string, a ...interface{}) *CloudError
- func NewConflictError(resourceID *azcorearm.ResourceID, format string, a ...interface{}) *CloudError
- func NewContentValidationError(errors []CloudErrorBody) *CloudError
- func NewInternalServerError() *CloudError
- func NewInvalidRequestContentError(err error) *CloudError
- func NewResourceNotFoundError(resourceID *azcorearm.ResourceID) *CloudError
- type CloudErrorBody
- type CorrelationData
- type CreatedByType
- type DeploymentPreflight
- type DeploymentPreflightResource
- type DeploymentPreflightResponse
- type DeploymentPreflightStatus
- type ExternalAuthProvisioningState
- type Feature
- type ManagedServiceIdentity
- type ManagedServiceIdentityType
- type Operation
- type PagedResponse
- type ProvisioningState
- type ProxyResource
- type Resource
- type Subscription
- type SubscriptionProperties
- type SubscriptionState
- type SystemData
- type TrackedResource
- type UserAssignedIdentity
- type ZoneMapping
Constants ¶
const ( CloudErrorCodeInternalServerError = "InternalServerError" CloudErrorCodeInvalidParameter = "InvalidParameter" CloudErrorCodeInvalidRequestContent = "InvalidRequestContent" CloudErrorCodeInvalidResource = "InvalidResource" CloudErrorCodeInvalidResourceType = "InvalidResourceType" CloudErrorCodeMultipleErrorsOccurred = "MultipleErrorsOccurred" CloudErrorCodeUnsupportedMediaType = "UnsupportedMediaType" CloudErrorCodeCanceled = "Canceled" CloudErrorCodeConflict = "Conflict" CloudErrorCodeNotFound = "NotFound" CloudErrorCodeInvalidSubscriptionState = "InvalidSubscriptionState" CloudErrorCodeSubscriptionNotFound = "SubscriptionNotFound" CloudErrorCodeResourceNotFound = "ResourceNotFound" CloudErrorCodeResourceGroupNotFound = "ResourceGroupNotFound" CloudErrorCodeInvalidSubscriptionID = "InvalidSubscriptionID" CloudErrorCodeInvalidResourceName = "InvalidResourceName" CloudErrorCodeInvalidResourceGroupName = "InvalidResourceGroupName" )
CloudError codes
const ( // Azure-specific HTTP header names HeaderNameAsyncOperation = "Azure-AsyncOperation" HeaderNameAsyncNotification = "Azure-AsyncNotification" HeaderNameAsyncNotificationURI = "Azure-AsyncNotificationUri" // Microsoft-specific HTTP header names HeaderNameErrorCode = "X-Ms-Error-Code" HeaderNameHomeTenantID = "X-Ms-Home-Tenant-Id" HeaderNameClientObjectID = "X-Ms-Client-Object-Id" HeaderNameRequestID = "X-Ms-Request-Id" HeaderNameClientRequestID = "X-Ms-Client-Request-Id" HeaderNameCorrelationRequestID = "X-Ms-Correlation-Request-Id" HeaderNameReturnClientRequestID = "X-Ms-Return-Client-Request-Id" HeaderNameARMResourceSystemData = "X-Ms-Arm-Resource-System-Data" HeaderNameIdentityURL = "X-Ms-Identity-Url" HeaderClientPrincipalName = "X-Ms-Client-Principal-Name" )
const SubscriptionAPIVersion = "2.0"
SubscriptionAPIVersion is the system API version for the subscription endpoint.
Variables ¶
This section is empty.
Functions ¶
func DetectTLE ¶
DetectTLE returns true if a Template Language Expression is detected in any part of the JSON input.
func ListProvisioningStates ¶
func ListProvisioningStates() iter.Seq[ProvisioningState]
ListProvisioningStates returns an iterator that yields all recognized ProvisioningState values. This function is intended as a test aid.
func ListSubscriptionStates ¶
func ListSubscriptionStates() iter.Seq[SubscriptionState]
ListSubscriptionStates returns an iterator that yields all recognized SubscriptionState values. This function is intended as a test aid.
func MarshalJSON ¶
MarshalJSON returns the JSON encoding of v.
Call this function instead of the marshal functions in "encoding/json" for HTTP responses to ensure the formatting is consistent.
Note, there is nothing ARM-specific about this function other than all ARM response bodies are JSON-formatted. But the "arm" package is currently the lowest layer insofar as it has no dependencies on other ARO-HCP packages.
func UnmarshalDeploymentPreflight ¶
func UnmarshalDeploymentPreflight(data []byte) (*DeploymentPreflight, *CloudError)
UnmarshalDeploymentPreflight unmarshals JSON-encoded data and returns either a DeploymentPreflight instance or an appropriate CloudError with a 200 OK HTTP status code.
func WriteCloudError ¶
func WriteCloudError(w http.ResponseWriter, err *CloudError)
WriteCloudError writes a CloudError to the given ResponseWriter
func WriteConflictError ¶
func WriteConflictError(w http.ResponseWriter, resourceID *azcorearm.ResourceID, format string, a ...interface{})
WriteConflictError writes a conflict error to the given ResponseWriter
func WriteDeploymentPreflightResponse ¶
func WriteDeploymentPreflightResponse(w http.ResponseWriter, preflightErrors []CloudErrorBody)
WriteDeploymentPreflightResponse writes an appropriately structured response body to a deployment preflight request using the given error slice. An empty error slice indicates successful validation.
func WriteError ¶
func WriteError(w http.ResponseWriter, statusCode int, code, target, format string, a ...interface{})
WriteError constructs and writes a CloudError to the given ResponseWriter
func WriteInternalServerError ¶
func WriteInternalServerError(w http.ResponseWriter)
WriteInternalServerError writes an internal server error to the given ResponseWriter
func WriteInvalidRequestContentError ¶
func WriteInvalidRequestContentError(w http.ResponseWriter, err error)
WriteInvalidRequestContentError writes an invalid request content error to the given ResponseWriter
func WriteJSONResponse ¶
WriteJSONResponse writes a JSON response body to the http.ResponseWriter in the proper sequence: first setting Content-Type to "application/json", then setting the HTTP status code, and finally writing a JSON encoding of body.
The function accepts anything for the body argument that can be marshalled to JSON. One special case, however, is a byte slice. A byte slice will be written verbatim with the expectation that it was produced by Marshal.
Note, there is nothing ARM-specific about this function other than all ARM response bodies are JSON-formatted. But the "arm" package is currently the lowest layer insofar as it has no dependencies on other ARO-HCP packages.
func WriteResourceNotFoundError ¶
func WriteResourceNotFoundError(w http.ResponseWriter, resourceID *azcorearm.ResourceID)
WriteResourceNotFoundError writes a nonexistent resource error to the given ResponseWriter
Types ¶
type AccountOwner ¶
type AvailabilityZone ¶
type AvailabilityZone struct { Location *string `json:"location,omitempty"` ZoneMappings *[]ZoneMapping `json:"zoneMappings,omitempty"` }
type CloudError ¶
type CloudError struct { // The HTTP status code StatusCode int `json:"-"` // The response body to be converted to JSON *CloudErrorBody `json:"error,omitempty"` }
CloudError represents a complete resource provider error.
func NewCloudError ¶
func NewCloudError(statusCode int, code, target, format string, a ...interface{}) *CloudError
NewCloudError returns a new CloudError
func NewConflictError ¶
func NewConflictError(resourceID *azcorearm.ResourceID, format string, a ...interface{}) *CloudError
NewConflictError creates a CloudError for a conflict error
func NewContentValidationError ¶
func NewContentValidationError(errors []CloudErrorBody) *CloudError
NewContentValidationError creates a CloudError from a slice of validation errors. For convenience, if the slice is empty then NewContentValidationError returns nil.
func NewInternalServerError ¶
func NewInternalServerError() *CloudError
NewInternalServerError creates a CloudError for an internal server error
func NewInvalidRequestContentError ¶
func NewInvalidRequestContentError(err error) *CloudError
NewInvalidRequestContentError creates a CloudError for an invalid request content error
func NewResourceNotFoundError ¶
func NewResourceNotFoundError(resourceID *azcorearm.ResourceID) *CloudError
NewResourceNotFoundError creates a CloudError for a nonexistent resource error
func (*CloudError) Error ¶
func (err *CloudError) Error() string
type CloudErrorBody ¶
type CloudErrorBody struct { // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Code string `json:"code,omitempty"` // A message describing the error, intended to be suitable for display in a user interface. Message string `json:"message,omitempty"` // The target of the particular error. For example, the name of the property in error. Target string `json:"target,omitempty"` // A list of additional details about the error. Details []CloudErrorBody `json:"details,omitempty"` }
CloudErrorBody represents the structure of the response body for a resource provider error. See https://github.com/cloud-and-ai-microsoft/resource-provider-contract/blob/master/v1.0/common-api-details.md#error-response-content
func NewCloudErrorBodyFromSlice ¶
func NewCloudErrorBodyFromSlice(errors []CloudErrorBody, multipleErrorsMessage string) *CloudErrorBody
NewCloudErrorBodyFromSlice converts a CloudErrorBody slice to a single CloudErrorBody. If there is only one item in the provided slice, that item is returned directly. If there are multiple items in the provided slice, a CloudErrorBody is returned with the code "MultipleErrorsOccurred", the multipleErrorsMessage, and the Details field set to the provided slice. If the provided slice is empty, the function returns nil.
func (*CloudErrorBody) String ¶
func (body *CloudErrorBody) String() string
type CorrelationData ¶
type CorrelationData struct { // RequestID is a generated unique identifier for the current operation. RequestID uuid.UUID // ClientRequestID contains the value of header "x-ms-client-request-id". ClientRequestID string `json:"clientRequestId,omitempty"` // CorrelationRequestID contains the value of header "x-ms-correlation-request-id". CorrelationRequestID string `json:"correlationRequestId,omitempty"` // ClientPrincipalName contains the value of header "x-ms-client-principal-name". ClientPrincipalName string `json:"clientPrincipalName,omitempty"` }
CorrelationData represents any data used for metrics or tracing. See: https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-details.md
func NewCorrelationData ¶
func NewCorrelationData(r *http.Request) *CorrelationData
NewCorrelationData allocates and initializes a new CorrelationData from HTTP request headers.
type CreatedByType ¶
type CreatedByType string
CreatedByType is the type of identity that created (or modified) the resource
const ( CreatedByTypeApplication CreatedByType = "Application" CreatedByTypeKey CreatedByType = "Key" CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" CreatedByTypeUser CreatedByType = "User" )
type DeploymentPreflight ¶
type DeploymentPreflight struct {
Resources []json.RawMessage `json:"resources"`
}
DeploymentPreflight represents the body of a deployment preflight request. We use a RawMessage slice here because preflight validation is best effort. So if one resource cannot be unmarshaled we move on to the next instead of failing the whole operation.
type DeploymentPreflightResource ¶
type DeploymentPreflightResource struct { Name string `json:"name" validate:"required"` Type string `json:"type" validate:"required"` Location string `json:"location" validate:"required"` APIVersion string `json:"apiVersion,omitempty" validate:"required,api_version"` // Preserve other tracked resource fields as raw data. Identity json.RawMessage `json:"identity,omitempty"` Properties json.RawMessage `json:"properties,omitempty"` Tags json.RawMessage `json:"tags,omitempty"` }
DeploymentPreflightResource represents a desired resource in a deployment preflight request.
func (*DeploymentPreflightResource) Convert ¶
func (r *DeploymentPreflightResource) Convert(v any) error
Convert discards the APIVersion, marshals itself back to raw JSON, and then unmarshals the raw JSON to the given value, which should be an extension of the TrackedResource type.
func (*DeploymentPreflightResource) ResourceID ¶
func (r *DeploymentPreflightResource) ResourceID(subscriptionID, resourceGroup string) string
ResourceID returns a resource ID string for the resource.
type DeploymentPreflightResponse ¶
type DeploymentPreflightResponse struct { Status DeploymentPreflightStatus `json:"status"` Error *CloudErrorBody `json:"error,omitempty"` }
DeploymentPreflightResponse represents the JSON response structure for a deployment preflight request.
type DeploymentPreflightStatus ¶
type DeploymentPreflightStatus string
DeploymentPreflightStatus is used in a DeploymentPreflightResponse.
const ( DeploymentPreflightStatusSucceeded DeploymentPreflightStatus = "Succeeded" DeploymentPreflightStatusFailed DeploymentPreflightStatus = "Failed" )
type ExternalAuthProvisioningState ¶
type ExternalAuthProvisioningState string
const ( // Terminal states, defined by ARM ExternalAuthProvisioningStateCanceled ExternalAuthProvisioningState = "Canceled" ExternalAuthProvisioningStateFailed ExternalAuthProvisioningState = "Failed" ExternalAuthProvisioningStateSucceeded ExternalAuthProvisioningState = "Succeeded" // Non-terminal states, defined by ARO-HCP ExternalAuthProvisioningStateAccepted ExternalAuthProvisioningState = "Accepted" ExternalAuthProvisioningStateAwaitingSecret ExternalAuthProvisioningState = "AwaitingSecret" ExternalAuthProvisioningStateDeleting ExternalAuthProvisioningState = "Deleting" ExternalAuthProvisioningStateProvisioning ExternalAuthProvisioningState = "Provisioning" ExternalAuthProvisioningStateUpdating ExternalAuthProvisioningState = "Updating" )
type ManagedServiceIdentity ¶
type ManagedServiceIdentity struct { PrincipalID string `json:"principalId,omitempty" visibility:"read"` TenantID string `json:"tenantId,omitempty" visibility:"read"` Type ManagedServiceIdentityType `json:"type" validate:"required,enum_managedserviceidentitytype"` UserAssignedIdentities map[string]*UserAssignedIdentity `` /* 147-byte string literal not displayed */ }
Represents to support the ManagedServiceIdentity ARM resource.
type ManagedServiceIdentityType ¶
type ManagedServiceIdentityType string
const ( ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" )
type Operation ¶
type Operation struct { ID *azcorearm.ResourceID `json:"id,omitempty"` Name string `json:"name,omitempty"` Status ProvisioningState `json:"status"` StartTime *time.Time `json:"startTime,omitempty"` EndTime *time.Time `json:"endTime,omitempty"` PercentComplete float64 `json:"percentComplete,omitempty"` Properties json.RawMessage `json:"properties,omitempty"` Error *CloudErrorBody `json:"error,omitempty"` Operations []Operation `json:"operations,omitempty"` }
Operation is an ARM-defined resource returned by operation status endpoints.
type PagedResponse ¶
type PagedResponse struct { Value []json.RawMessage `json:"value"` NextLink string `json:"nextLink,omitempty"` }
PagedResponse is the response format for resource collection requests.
func NewPagedResponse ¶
func NewPagedResponse() PagedResponse
NewPagedResponse returns a new PagedResponse instance.
func (*PagedResponse) AddValue ¶
func (r *PagedResponse) AddValue(value json.RawMessage)
AddValue adds a JSON encoded value to a PagedResponse.
func (*PagedResponse) SetNextLink ¶
func (r *PagedResponse) SetNextLink(baseURL, skipToken string) error
SetNextLink sets NextLink to a URL with a $skipToken parameter. If skipToken is empty, the function does nothing and returns nil.
type ProvisioningState ¶
type ProvisioningState string
ProvisioningState represents the asynchronous provisioning state of an ARM resource See https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#provisioningstate-property
const ( // Terminal states, defined by ARM ProvisioningStateSucceeded ProvisioningState = "Succeeded" ProvisioningStateFailed ProvisioningState = "Failed" ProvisioningStateCanceled ProvisioningState = "Canceled" // Non-terminal states, defined by ARO-HCP ProvisioningStateAccepted ProvisioningState = "Accepted" ProvisioningStateDeleting ProvisioningState = "Deleting" ProvisioningStateProvisioning ProvisioningState = "Provisioning" ProvisioningStateUpdating ProvisioningState = "Updating" )
func (ProvisioningState) IsTerminal ¶
func (s ProvisioningState) IsTerminal() bool
IsTerminal returns true if the state is terminal.
type ProxyResource ¶
type ProxyResource struct {
Resource
}
ProxyResource represents an ARM resource without location/tags
func (*ProxyResource) Copy ¶
func (src *ProxyResource) Copy(dst *ProxyResource)
type Resource ¶
type Resource struct { ID string `json:"id,omitempty" visibility:"read"` Name string `json:"name,omitempty" visibility:"read"` Type string `json:"type,omitempty" visibility:"read"` SystemData *SystemData `json:"systemData,omitempty" visibility:"read"` }
Resource represents a basic ARM resource
type Subscription ¶
type Subscription struct { // The resource provider contract gives an example RegistrationDate // in RFC1123 format but does not explicitly state a required format // so we leave it a plain string. State SubscriptionState `json:"state" validate:"required,enum_subscriptionstate"` RegistrationDate *string `json:"registrationDate" validate:"required"` Properties *SubscriptionProperties `json:"properties"` // LastUpdated is a copy of the Cosmos DB system generated // "_ts" last updated timestamp field for metrics reporting. LastUpdated int `json:"-"` }
func (Subscription) GetValidTypes ¶
func (s Subscription) GetValidTypes() []string
GetValidTypes returns the valid resource types for a Subscription.
type SubscriptionProperties ¶
type SubscriptionProperties struct { TenantId *string `json:"tenantId,omitempty"` LocationPlacementId *string `json:"locationPlacementId,omitempty"` QuotaId *string `json:"quotaId,omitempty"` RegisteredFeatures *[]Feature `json:"registeredFeatures,omitempty"` AvailabilityZones *AvailabilityZone `json:"availabilityZones,omitempty"` SpendingLimit *string `json:"spendingLimit,omitempty"` AccountOwner *AccountOwner `json:"accountOwner,omitempty"` ManagedByTenants *[]map[string]string `json:"managedByTenants,omitempty"` AdditionalProperties any `json:"additionalProperties,omitempty"` }
type SubscriptionState ¶
type SubscriptionState string
const ( SubscriptionStateRegistered SubscriptionState = "Registered" SubscriptionStateUnregistered SubscriptionState = "Unregistered" SubscriptionStateWarned SubscriptionState = "Warned" SubscriptionStateDeleted SubscriptionState = "Deleted" SubscriptionStateSuspended SubscriptionState = "Suspended" )
type SystemData ¶
type SystemData struct { // CreatedBy is a string identifier for the identity that created the resource CreatedBy string `json:"createdBy,omitempty"` // CreatedByType is the type of identity that created the resource: User, Application, ManagedIdentity CreatedByType CreatedByType `json:"createdByType,omitempty"` // The timestamp of resource creation (UTC) CreatedAt *time.Time `json:"createdAt,omitempty"` // LastModifiedBy is a string identifier for the identity that last modified the resource LastModifiedBy string `json:"lastModifiedBy,omitempty"` // LastModifiedByType is the type of identity that last modified the resource: User, Application, ManagedIdentity LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` // LastModifiedAt is the timestamp of resource last modification (UTC) LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` }
SystemData includes creation and modification metadata for resources See https://eng.ms/docs/products/arm/api_contracts/resourcesystemdata
func (*SystemData) Copy ¶
func (src *SystemData) Copy(dst *SystemData)
type TrackedResource ¶
type TrackedResource struct { Resource Location string `json:"location,omitempty" visibility:"read create" validate:"required"` Tags map[string]string `json:"tags,omitempty" visibility:"read create update"` }
TrackedResource represents a tracked ARM resource
func (*TrackedResource) Copy ¶
func (src *TrackedResource) Copy(dst *TrackedResource)
type UserAssignedIdentity ¶
type UserAssignedIdentity struct { ClientID *string `json:"clientId,omitempty" visibility:"read"` PrincipalID *string `json:"principalId,omitempty" visibility:"read"` }
UserAssignedIdentity - User assigned identity properties https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/reference/data-types/#Azure.ResourceManager.CommonTypes.UserAssignedIdentity