armlocks

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: MIT Imports: 14 Imported by: 2

README

Azure Resource Lock Module for Go

PkgGoDev

The armlocks module provides operations for working with Azure Resource Lock.

Source code

Getting started

Prerequisites

  • an Azure subscription
  • Go 1.18 or above (You could download and install the latest version of Go from here. It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this doc.)

Install the package

This project uses Go modules for versioning and dependency management.

Install the Azure Resource Lock module:

go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks

Authorization

When creating a client, you will need to provide a credential for authenticating with Azure Resource Lock. The azidentity module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more.

cred, err := azidentity.NewDefaultAzureCredential(nil)

For more information on authentication, please see the documentation for azidentity at pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity.

Client Factory

Azure Resource Lock module consists of one or more clients. We provide a client factory which could be used to create any client in this module.

clientFactory, err := armlocks.NewClientFactory(<subscription ID>, cred, nil)

You can use ClientOptions in package github.com/Azure/azure-sdk-for-go/sdk/azcore/arm to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for azcore at pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore.

options := arm.ClientOptions {
    ClientOptions: azcore.ClientOptions {
        Cloud: cloud.AzureChina,
    },
}
clientFactory, err := armlocks.NewClientFactory(<subscription ID>, cred, &options)

Clients

A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory.

client := clientFactory.NewManagementLocksClient()

Fakes

The fake package contains types used for constructing in-memory fake servers used in unit tests. This allows writing tests to cover various success/error conditions without the need for connecting to a live service.

Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes.

Provide Feedback

If you encounter bugs or have suggestions, please open an issue and assign the Resource Lock label.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationOperationsClient

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

AuthorizationOperationsClient contains the methods for the AuthorizationOperations group. Don't use this type directly, use NewAuthorizationOperationsClient() instead.

func NewAuthorizationOperationsClient

func NewAuthorizationOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*AuthorizationOperationsClient, error)

NewAuthorizationOperationsClient creates a new instance of AuthorizationOperationsClient with the specified values.

  • credential - used to authorize requests. Usually a credential from azidentity.
  • options - pass nil to accept the default values.

func (*AuthorizationOperationsClient) NewListPager added in v0.4.0

NewListPager - Lists all of the available Microsoft.Authorization REST API operations.

Generated from API version 2020-05-01

  • options - AuthorizationOperationsClientListOptions contains the optional parameters for the AuthorizationOperationsClient.NewListPager method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ListProviderOperations.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewAuthorizationOperationsClient().NewListPager(nil)
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Value {
			// You could use page here. We use blank identifier for just demo purposes.
			_ = v
		}
		// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
		// page.OperationListResult = armlocks.OperationListResult{
		// 	Value: []*armlocks.Operation{
		// 		{
		// 			Name: to.Ptr("Microsoft.Authorization/locks/read"),
		// 			Display: &armlocks.OperationDisplay{
		// 				Operation: to.Ptr("read"),
		// 				Provider: to.Ptr("Microsoft.Authorization"),
		// 				Resource: to.Ptr("locks"),
		// 			},
		// 	}},
		// }
	}
}
Output:

type AuthorizationOperationsClientListOptions added in v0.2.0

type AuthorizationOperationsClientListOptions struct {
}

AuthorizationOperationsClientListOptions contains the optional parameters for the AuthorizationOperationsClient.NewListPager method.

type AuthorizationOperationsClientListResponse added in v0.2.0

type AuthorizationOperationsClientListResponse struct {
	// Result of the request to list Microsoft.Authorization operations. It contains a list of operations and a URL link to get
	// the next set of results.
	OperationListResult
}

AuthorizationOperationsClientListResponse contains the response from method AuthorizationOperationsClient.NewListPager.

type ClientFactory added in v1.1.0

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

ClientFactory is a client factory used to create any client in this module. Don't use this type directly, use NewClientFactory instead.

func NewClientFactory added in v1.1.0

func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error)

NewClientFactory creates a new instance of ClientFactory with the specified values. The parameter values will be propagated to any client created from this factory.

  • subscriptionID - The ID of the target subscription.
  • credential - used to authorize requests. Usually a credential from azidentity.
  • options - pass nil to accept the default values.

func (*ClientFactory) NewAuthorizationOperationsClient added in v1.1.0

func (c *ClientFactory) NewAuthorizationOperationsClient() *AuthorizationOperationsClient

NewAuthorizationOperationsClient creates a new instance of AuthorizationOperationsClient.

func (*ClientFactory) NewManagementLocksClient added in v1.1.0

func (c *ClientFactory) NewManagementLocksClient() *ManagementLocksClient

NewManagementLocksClient creates a new instance of ManagementLocksClient.

type CreatedByType

type CreatedByType string

CreatedByType - The type of identity that created the resource.

const (
	CreatedByTypeApplication     CreatedByType = "Application"
	CreatedByTypeKey             CreatedByType = "Key"
	CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity"
	CreatedByTypeUser            CreatedByType = "User"
)

func PossibleCreatedByTypeValues

func PossibleCreatedByTypeValues() []CreatedByType

PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type.

type ErrorAdditionalInfo

type ErrorAdditionalInfo struct {
	// READ-ONLY; The additional info.
	Info any

	// READ-ONLY; The additional info type.
	Type *string
}

ErrorAdditionalInfo - The resource management error additional info.

func (ErrorAdditionalInfo) MarshalJSON added in v1.1.0

func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo.

func (*ErrorAdditionalInfo) UnmarshalJSON added in v1.1.0

func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo.

type ErrorDetail

type ErrorDetail struct {
	// READ-ONLY; The error additional info.
	AdditionalInfo []*ErrorAdditionalInfo

	// READ-ONLY; The error code.
	Code *string

	// READ-ONLY; The error details.
	Details []*ErrorDetail

	// READ-ONLY; The error message.
	Message *string

	// READ-ONLY; The error target.
	Target *string
}

ErrorDetail - The error detail.

func (ErrorDetail) MarshalJSON

func (e ErrorDetail) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ErrorDetail.

func (*ErrorDetail) UnmarshalJSON added in v1.1.0

func (e *ErrorDetail) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail.

type ErrorResponse

type ErrorResponse struct {
	// The error object.
	Error *ErrorDetail
}

ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).

func (ErrorResponse) MarshalJSON added in v1.1.0

func (e ErrorResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ErrorResponse.

func (*ErrorResponse) UnmarshalJSON added in v1.1.0

func (e *ErrorResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse.

type LockLevel

type LockLevel string

LockLevel - The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but not delete. ReadOnly means authorized users can only read from a resource, but they can't modify or delete it.

const (
	LockLevelCanNotDelete LockLevel = "CanNotDelete"
	LockLevelNotSpecified LockLevel = "NotSpecified"
	LockLevelReadOnly     LockLevel = "ReadOnly"
)

func PossibleLockLevelValues

func PossibleLockLevelValues() []LockLevel

PossibleLockLevelValues returns the possible values for the LockLevel const type.

type ManagementLockListResult

type ManagementLockListResult struct {
	// The URL to use for getting the next set of results.
	NextLink *string

	// The list of locks.
	Value []*ManagementLockObject
}

ManagementLockListResult - The list of locks.

func (ManagementLockListResult) MarshalJSON

func (m ManagementLockListResult) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ManagementLockListResult.

func (*ManagementLockListResult) UnmarshalJSON added in v1.1.0

func (m *ManagementLockListResult) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ManagementLockListResult.

type ManagementLockObject

type ManagementLockObject struct {
	// REQUIRED; The properties of the lock.
	Properties *ManagementLockProperties

	// READ-ONLY; The resource ID of the lock.
	ID *string

	// READ-ONLY; The name of the lock.
	Name *string

	// READ-ONLY; Metadata pertaining to creation and last modification of the resource.
	SystemData *SystemData

	// READ-ONLY; The resource type of the lock - Microsoft.Authorization/locks.
	Type *string
}

ManagementLockObject - The lock information.

func (ManagementLockObject) MarshalJSON added in v1.1.0

func (m ManagementLockObject) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ManagementLockObject.

func (*ManagementLockObject) UnmarshalJSON added in v1.1.0

func (m *ManagementLockObject) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ManagementLockObject.

type ManagementLockOwner

type ManagementLockOwner struct {
	// The application ID of the lock owner.
	ApplicationID *string
}

ManagementLockOwner - Lock owner properties.

func (ManagementLockOwner) MarshalJSON added in v1.1.0

func (m ManagementLockOwner) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ManagementLockOwner.

func (*ManagementLockOwner) UnmarshalJSON added in v1.1.0

func (m *ManagementLockOwner) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ManagementLockOwner.

type ManagementLockProperties

type ManagementLockProperties struct {
	// REQUIRED; The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized
	// users are able to read and modify the resources, but not delete. ReadOnly means
	// authorized users can only read from a resource, but they can't modify or delete it.
	Level *LockLevel

	// Notes about the lock. Maximum of 512 characters.
	Notes *string

	// The owners of the lock.
	Owners []*ManagementLockOwner
}

ManagementLockProperties - The lock properties.

func (ManagementLockProperties) MarshalJSON

func (m ManagementLockProperties) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type ManagementLockProperties.

func (*ManagementLockProperties) UnmarshalJSON added in v1.1.0

func (m *ManagementLockProperties) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type ManagementLockProperties.

type ManagementLocksClient

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

ManagementLocksClient contains the methods for the ManagementLocks group. Don't use this type directly, use NewManagementLocksClient() instead.

func NewManagementLocksClient

func NewManagementLocksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagementLocksClient, error)

NewManagementLocksClient creates a new instance of ManagementLocksClient with the specified values.

  • subscriptionID - The ID of the target subscription.
  • credential - used to authorize requests. Usually a credential from azidentity.
  • options - pass nil to accept the default values.

func (*ManagementLocksClient) CreateOrUpdateAtResourceGroupLevel

CreateOrUpdateAtResourceGroupLevel - When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2020-05-01

  • resourceGroupName - The name of the resource group to lock.
  • lockName - The lock name. The lock name can be a maximum of 260 characters. It cannot contain %, &, :, \, ?, /, or any control characters.
  • parameters - The management lock parameters.
  • options - ManagementLocksClientCreateOrUpdateAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateAtResourceGroupLevel method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceGroupLevel.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewManagementLocksClient().CreateOrUpdateAtResourceGroupLevel(ctx, "resourcegroupname", "testlock", armlocks.ManagementLockObject{
		Properties: &armlocks.ManagementLockProperties{
			Level: to.Ptr(armlocks.LockLevelReadOnly),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.ManagementLockObject = armlocks.ManagementLockObject{
	// 	Name: to.Ptr("testlock"),
	// 	Type: to.Ptr("Microsoft.Authorization/locks"),
	// 	ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"),
	// 	Properties: &armlocks.ManagementLockProperties{
	// 		Level: to.Ptr(armlocks.LockLevelReadOnly),
	// 	},
	// }
}
Output:

func (*ManagementLocksClient) CreateOrUpdateAtResourceLevel

func (client *ManagementLocksClient) CreateOrUpdateAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, parameters ManagementLockObject, options *ManagementLocksClientCreateOrUpdateAtResourceLevelOptions) (ManagementLocksClientCreateOrUpdateAtResourceLevelResponse, error)

CreateOrUpdateAtResourceLevel - When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2020-05-01

  • resourceGroupName - The name of the resource group containing the resource to lock.
  • resourceProviderNamespace - The resource provider namespace of the resource to lock.
  • parentResourcePath - The parent resource identity.
  • resourceType - The resource type of the resource to lock.
  • resourceName - The name of the resource to lock.
  • lockName - The name of lock. The lock name can be a maximum of 260 characters. It cannot contain %, &, :, \, ?, /, or any control characters.
  • parameters - Parameters for creating or updating a management lock.
  • options - ManagementLocksClientCreateOrUpdateAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateAtResourceLevel method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceLevel.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewManagementLocksClient().CreateOrUpdateAtResourceLevel(ctx, "resourcegroupname", "Microsoft.Storage", "parentResourcePath", "storageAccounts", "teststorageaccount", "testlock", armlocks.ManagementLockObject{
		Properties: &armlocks.ManagementLockProperties{
			Level: to.Ptr(armlocks.LockLevelReadOnly),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.ManagementLockObject = armlocks.ManagementLockObject{
	// 	Name: to.Ptr("testlock"),
	// 	Type: to.Ptr("Microsoft.Authorization/locks"),
	// 	ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"),
	// 	Properties: &armlocks.ManagementLockProperties{
	// 		Level: to.Ptr(armlocks.LockLevelReadOnly),
	// 	},
	// }
}
Output:

func (*ManagementLocksClient) CreateOrUpdateAtSubscriptionLevel

CreateOrUpdateAtSubscriptionLevel - When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2020-05-01

  • lockName - The name of lock. The lock name can be a maximum of 260 characters. It cannot contain %, &, :, \, ?, /, or any control characters.
  • parameters - The management lock parameters.
  • options - ManagementLocksClientCreateOrUpdateAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateAtSubscriptionLevel method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtSubscriptionLevel.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewManagementLocksClient().CreateOrUpdateAtSubscriptionLevel(ctx, "testlock", armlocks.ManagementLockObject{
		Properties: &armlocks.ManagementLockProperties{
			Level: to.Ptr(armlocks.LockLevelReadOnly),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.ManagementLockObject = armlocks.ManagementLockObject{
	// 	Name: to.Ptr("testlock"),
	// 	Type: to.Ptr("Microsoft.Authorization/locks"),
	// 	ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"),
	// 	Properties: &armlocks.ManagementLockProperties{
	// 		Level: to.Ptr(armlocks.LockLevelReadOnly),
	// 	},
	// }
}
Output:

func (*ManagementLocksClient) CreateOrUpdateByScope

CreateOrUpdateByScope - Create or update a management lock by scope. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2020-05-01

  • scope - The scope for the lock. When providing a scope for the assignment, use '/subscriptions/{subscriptionId}' for subscriptions, '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' for resources.
  • lockName - The name of lock.
  • parameters - Create or update management lock parameters.
  • options - ManagementLocksClientCreateOrUpdateByScopeOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateByScope method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewManagementLocksClient().CreateOrUpdateByScope(ctx, "subscriptions/subscriptionId", "testlock", armlocks.ManagementLockObject{
		Properties: &armlocks.ManagementLockProperties{
			Level: to.Ptr(armlocks.LockLevelReadOnly),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.ManagementLockObject = armlocks.ManagementLockObject{
	// 	Name: to.Ptr("testlock"),
	// 	Type: to.Ptr("Microsoft.Authorization/locks"),
	// 	ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"),
	// 	Properties: &armlocks.ManagementLockProperties{
	// 		Level: to.Ptr(armlocks.LockLevelReadOnly),
	// 	},
	// }
}
Output:

func (*ManagementLocksClient) DeleteAtResourceGroupLevel

DeleteAtResourceGroupLevel - To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2020-05-01

  • resourceGroupName - The name of the resource group containing the lock.
  • lockName - The name of lock to delete.
  • options - ManagementLocksClientDeleteAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.DeleteAtResourceGroupLevel method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceGroupLevel.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewManagementLocksClient().DeleteAtResourceGroupLevel(ctx, "resourcegroupname", "testlock", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Output:

func (*ManagementLocksClient) DeleteAtResourceLevel

func (client *ManagementLocksClient) DeleteAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, options *ManagementLocksClientDeleteAtResourceLevelOptions) (ManagementLocksClientDeleteAtResourceLevelResponse, error)

DeleteAtResourceLevel - To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2020-05-01

  • resourceGroupName - The name of the resource group containing the resource with the lock to delete.
  • resourceProviderNamespace - The resource provider namespace of the resource with the lock to delete.
  • parentResourcePath - The parent resource identity.
  • resourceType - The resource type of the resource with the lock to delete.
  • resourceName - The name of the resource with the lock to delete.
  • lockName - The name of the lock to delete.
  • options - ManagementLocksClientDeleteAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.DeleteAtResourceLevel method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceLevel.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewManagementLocksClient().DeleteAtResourceLevel(ctx, "resourcegroupname", "Microsoft.Storage", "parentResourcePath", "storageAccounts", "teststorageaccount", "testlock", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Output:

func (*ManagementLocksClient) DeleteAtSubscriptionLevel

DeleteAtSubscriptionLevel - To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2020-05-01

  • lockName - The name of lock to delete.
  • options - ManagementLocksClientDeleteAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.DeleteAtSubscriptionLevel method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtSubscriptionLevel.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewManagementLocksClient().DeleteAtSubscriptionLevel(ctx, "testlock", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Output:

func (*ManagementLocksClient) DeleteByScope

DeleteByScope - Delete a management lock by scope. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2020-05-01

  • scope - The scope for the lock.
  • lockName - The name of lock.
  • options - ManagementLocksClientDeleteByScopeOptions contains the optional parameters for the ManagementLocksClient.DeleteByScope method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtScope.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewManagementLocksClient().DeleteByScope(ctx, "subscriptions/subscriptionId", "testlock", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
Output:

func (*ManagementLocksClient) GetAtResourceGroupLevel

GetAtResourceGroupLevel - Gets a management lock at the resource group level. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2020-05-01

  • resourceGroupName - The name of the locked resource group.
  • lockName - The name of the lock to get.
  • options - ManagementLocksClientGetAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.GetAtResourceGroupLevel method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceGroupLevel.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewManagementLocksClient().GetAtResourceGroupLevel(ctx, "resourcegroupname", "testlock", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.ManagementLockObject = armlocks.ManagementLockObject{
	// 	Name: to.Ptr("testlock"),
	// 	Type: to.Ptr("Microsoft.Authorization/locks"),
	// 	ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"),
	// 	Properties: &armlocks.ManagementLockProperties{
	// 		Level: to.Ptr(armlocks.LockLevelReadOnly),
	// 	},
	// }
}
Output:

func (*ManagementLocksClient) GetAtResourceLevel

func (client *ManagementLocksClient) GetAtResourceLevel(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, options *ManagementLocksClientGetAtResourceLevelOptions) (ManagementLocksClientGetAtResourceLevelResponse, error)

GetAtResourceLevel - Get the management lock of a resource or any level below resource. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2020-05-01

  • resourceGroupName - The name of the resource group.
  • resourceProviderNamespace - The namespace of the resource provider.
  • parentResourcePath - An extra path parameter needed in some services, like SQL Databases.
  • resourceType - The type of the resource.
  • resourceName - The name of the resource.
  • lockName - The name of lock.
  • options - ManagementLocksClientGetAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.GetAtResourceLevel method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceLevel.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewManagementLocksClient().GetAtResourceLevel(ctx, "resourcegroupname", "Microsoft.Storage", "parentResourcePath", "storageAccounts", "teststorageaccount", "testlock", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.ManagementLockObject = armlocks.ManagementLockObject{
	// 	Name: to.Ptr("testlock"),
	// 	Type: to.Ptr("Microsoft.Authorization/locks"),
	// 	ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"),
	// 	Properties: &armlocks.ManagementLockProperties{
	// 		Level: to.Ptr(armlocks.LockLevelReadOnly),
	// 	},
	// }
}
Output:

func (*ManagementLocksClient) GetAtSubscriptionLevel

GetAtSubscriptionLevel - Gets a management lock at the subscription level. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2020-05-01

  • lockName - The name of the lock to get.
  • options - ManagementLocksClientGetAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.GetAtSubscriptionLevel method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtSubscriptionLevel.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewManagementLocksClient().GetAtSubscriptionLevel(ctx, "testlock", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.ManagementLockObject = armlocks.ManagementLockObject{
	// 	Name: to.Ptr("testlock"),
	// 	Type: to.Ptr("Microsoft.Authorization/locks"),
	// 	ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"),
	// 	Properties: &armlocks.ManagementLockProperties{
	// 		Level: to.Ptr(armlocks.LockLevelReadOnly),
	// 	},
	// }
}
Output:

func (*ManagementLocksClient) GetByScope

GetByScope - Get a management lock by scope. If the operation fails it returns an *azcore.ResponseError type.

Generated from API version 2020-05-01

  • scope - The scope for the lock.
  • lockName - The name of lock.
  • options - ManagementLocksClientGetByScopeOptions contains the optional parameters for the ManagementLocksClient.GetByScope method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewManagementLocksClient().GetByScope(ctx, "subscriptions/subscriptionId", "testlock", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.ManagementLockObject = armlocks.ManagementLockObject{
	// 	Name: to.Ptr("testlock"),
	// 	Type: to.Ptr("Microsoft.Authorization/locks"),
	// 	ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"),
	// 	Properties: &armlocks.ManagementLockProperties{
	// 		Level: to.Ptr(armlocks.LockLevelReadOnly),
	// 	},
	// }
}
Output:

func (*ManagementLocksClient) NewListAtResourceGroupLevelPager added in v0.4.0

NewListAtResourceGroupLevelPager - Gets all the management locks for a resource group.

Generated from API version 2020-05-01

  • resourceGroupName - The name of the resource group containing the locks to get.
  • options - ManagementLocksClientListAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.NewListAtResourceGroupLevelPager method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceGroupLevel.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewManagementLocksClient().NewListAtResourceGroupLevelPager("resourcegroupname", &armlocks.ManagementLocksClientListAtResourceGroupLevelOptions{Filter: nil})
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Value {
			// You could use page here. We use blank identifier for just demo purposes.
			_ = v
		}
		// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
		// page.ManagementLockListResult = armlocks.ManagementLockListResult{
		// 	Value: []*armlocks.ManagementLockObject{
		// 		{
		// 			Name: to.Ptr("testlock"),
		// 			Type: to.Ptr("Microsoft.Authorization/locks"),
		// 			ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"),
		// 			Properties: &armlocks.ManagementLockProperties{
		// 				Level: to.Ptr(armlocks.LockLevelReadOnly),
		// 			},
		// 	}},
		// }
	}
}
Output:

func (*ManagementLocksClient) NewListAtResourceLevelPager added in v0.4.0

func (client *ManagementLocksClient) NewListAtResourceLevelPager(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *ManagementLocksClientListAtResourceLevelOptions) *runtime.Pager[ManagementLocksClientListAtResourceLevelResponse]

NewListAtResourceLevelPager - Gets all the management locks for a resource or any level below resource.

Generated from API version 2020-05-01

  • resourceGroupName - The name of the resource group containing the locked resource. The name is case insensitive.
  • resourceProviderNamespace - The namespace of the resource provider.
  • parentResourcePath - The parent resource identity.
  • resourceType - The resource type of the locked resource.
  • resourceName - The name of the locked resource.
  • options - ManagementLocksClientListAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.NewListAtResourceLevelPager method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceLevel.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewManagementLocksClient().NewListAtResourceLevelPager("resourcegroupname", "Microsoft.Storage", "parentResourcePath", "storageAccounts", "teststorageaccount", &armlocks.ManagementLocksClientListAtResourceLevelOptions{Filter: nil})
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Value {
			// You could use page here. We use blank identifier for just demo purposes.
			_ = v
		}
		// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
		// page.ManagementLockListResult = armlocks.ManagementLockListResult{
		// 	Value: []*armlocks.ManagementLockObject{
		// 		{
		// 			Name: to.Ptr("testlock"),
		// 			Type: to.Ptr("Microsoft.Authorization/locks"),
		// 			ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"),
		// 			Properties: &armlocks.ManagementLockProperties{
		// 				Level: to.Ptr(armlocks.LockLevelReadOnly),
		// 			},
		// 	}},
		// }
	}
}
Output:

func (*ManagementLocksClient) NewListAtSubscriptionLevelPager added in v0.4.0

NewListAtSubscriptionLevelPager - Gets all the management locks for a subscription.

Generated from API version 2020-05-01

  • options - ManagementLocksClientListAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.NewListAtSubscriptionLevelPager method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtSubscriptionLevel.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewManagementLocksClient().NewListAtSubscriptionLevelPager(&armlocks.ManagementLocksClientListAtSubscriptionLevelOptions{Filter: nil})
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Value {
			// You could use page here. We use blank identifier for just demo purposes.
			_ = v
		}
		// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
		// page.ManagementLockListResult = armlocks.ManagementLockListResult{
		// 	Value: []*armlocks.ManagementLockObject{
		// 		{
		// 			Name: to.Ptr("testlock"),
		// 			Type: to.Ptr("Microsoft.Authorization/locks"),
		// 			ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"),
		// 			Properties: &armlocks.ManagementLockProperties{
		// 				Level: to.Ptr(armlocks.LockLevelReadOnly),
		// 			},
		// 	}},
		// }
	}
}
Output:

func (*ManagementLocksClient) NewListByScopePager added in v0.4.0

NewListByScopePager - Gets all the management locks for a scope.

Generated from API version 2020-05-01

  • scope - The scope for the lock. When providing a scope for the assignment, use '/subscriptions/{subscriptionId}' for subscriptions, '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' for resources.
  • options - ManagementLocksClientListByScopeOptions contains the optional parameters for the ManagementLocksClient.NewListByScopePager method.
Example

Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtScope.json

package main

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks"
)

func main() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armlocks.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewManagementLocksClient().NewListByScopePager("subscriptions/subscriptionId", &armlocks.ManagementLocksClientListByScopeOptions{Filter: nil})
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Value {
			// You could use page here. We use blank identifier for just demo purposes.
			_ = v
		}
		// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
		// page.ManagementLockListResult = armlocks.ManagementLockListResult{
		// 	Value: []*armlocks.ManagementLockObject{
		// 		{
		// 			Name: to.Ptr("testlock"),
		// 			Type: to.Ptr("Microsoft.Authorization/locks"),
		// 			ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"),
		// 			Properties: &armlocks.ManagementLockProperties{
		// 				Level: to.Ptr(armlocks.LockLevelReadOnly),
		// 			},
		// 	}},
		// }
	}
}
Output:

type ManagementLocksClientCreateOrUpdateAtResourceGroupLevelOptions added in v0.2.0

type ManagementLocksClientCreateOrUpdateAtResourceGroupLevelOptions struct {
}

ManagementLocksClientCreateOrUpdateAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateAtResourceGroupLevel method.

type ManagementLocksClientCreateOrUpdateAtResourceGroupLevelResponse added in v0.2.0

type ManagementLocksClientCreateOrUpdateAtResourceGroupLevelResponse struct {
	// The lock information.
	ManagementLockObject
}

ManagementLocksClientCreateOrUpdateAtResourceGroupLevelResponse contains the response from method ManagementLocksClient.CreateOrUpdateAtResourceGroupLevel.

type ManagementLocksClientCreateOrUpdateAtResourceLevelOptions added in v0.2.0

type ManagementLocksClientCreateOrUpdateAtResourceLevelOptions struct {
}

ManagementLocksClientCreateOrUpdateAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateAtResourceLevel method.

type ManagementLocksClientCreateOrUpdateAtResourceLevelResponse added in v0.2.0

type ManagementLocksClientCreateOrUpdateAtResourceLevelResponse struct {
	// The lock information.
	ManagementLockObject
}

ManagementLocksClientCreateOrUpdateAtResourceLevelResponse contains the response from method ManagementLocksClient.CreateOrUpdateAtResourceLevel.

type ManagementLocksClientCreateOrUpdateAtSubscriptionLevelOptions added in v0.2.0

type ManagementLocksClientCreateOrUpdateAtSubscriptionLevelOptions struct {
}

ManagementLocksClientCreateOrUpdateAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateAtSubscriptionLevel method.

type ManagementLocksClientCreateOrUpdateAtSubscriptionLevelResponse added in v0.2.0

type ManagementLocksClientCreateOrUpdateAtSubscriptionLevelResponse struct {
	// The lock information.
	ManagementLockObject
}

ManagementLocksClientCreateOrUpdateAtSubscriptionLevelResponse contains the response from method ManagementLocksClient.CreateOrUpdateAtSubscriptionLevel.

type ManagementLocksClientCreateOrUpdateByScopeOptions added in v0.2.0

type ManagementLocksClientCreateOrUpdateByScopeOptions struct {
}

ManagementLocksClientCreateOrUpdateByScopeOptions contains the optional parameters for the ManagementLocksClient.CreateOrUpdateByScope method.

type ManagementLocksClientCreateOrUpdateByScopeResponse added in v0.2.0

type ManagementLocksClientCreateOrUpdateByScopeResponse struct {
	// The lock information.
	ManagementLockObject
}

ManagementLocksClientCreateOrUpdateByScopeResponse contains the response from method ManagementLocksClient.CreateOrUpdateByScope.

type ManagementLocksClientDeleteAtResourceGroupLevelOptions added in v0.2.0

type ManagementLocksClientDeleteAtResourceGroupLevelOptions struct {
}

ManagementLocksClientDeleteAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.DeleteAtResourceGroupLevel method.

type ManagementLocksClientDeleteAtResourceGroupLevelResponse added in v0.2.0

type ManagementLocksClientDeleteAtResourceGroupLevelResponse struct {
}

ManagementLocksClientDeleteAtResourceGroupLevelResponse contains the response from method ManagementLocksClient.DeleteAtResourceGroupLevel.

type ManagementLocksClientDeleteAtResourceLevelOptions added in v0.2.0

type ManagementLocksClientDeleteAtResourceLevelOptions struct {
}

ManagementLocksClientDeleteAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.DeleteAtResourceLevel method.

type ManagementLocksClientDeleteAtResourceLevelResponse added in v0.2.0

type ManagementLocksClientDeleteAtResourceLevelResponse struct {
}

ManagementLocksClientDeleteAtResourceLevelResponse contains the response from method ManagementLocksClient.DeleteAtResourceLevel.

type ManagementLocksClientDeleteAtSubscriptionLevelOptions added in v0.2.0

type ManagementLocksClientDeleteAtSubscriptionLevelOptions struct {
}

ManagementLocksClientDeleteAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.DeleteAtSubscriptionLevel method.

type ManagementLocksClientDeleteAtSubscriptionLevelResponse added in v0.2.0

type ManagementLocksClientDeleteAtSubscriptionLevelResponse struct {
}

ManagementLocksClientDeleteAtSubscriptionLevelResponse contains the response from method ManagementLocksClient.DeleteAtSubscriptionLevel.

type ManagementLocksClientDeleteByScopeOptions added in v0.2.0

type ManagementLocksClientDeleteByScopeOptions struct {
}

ManagementLocksClientDeleteByScopeOptions contains the optional parameters for the ManagementLocksClient.DeleteByScope method.

type ManagementLocksClientDeleteByScopeResponse added in v0.2.0

type ManagementLocksClientDeleteByScopeResponse struct {
}

ManagementLocksClientDeleteByScopeResponse contains the response from method ManagementLocksClient.DeleteByScope.

type ManagementLocksClientGetAtResourceGroupLevelOptions added in v0.2.0

type ManagementLocksClientGetAtResourceGroupLevelOptions struct {
}

ManagementLocksClientGetAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.GetAtResourceGroupLevel method.

type ManagementLocksClientGetAtResourceGroupLevelResponse added in v0.2.0

type ManagementLocksClientGetAtResourceGroupLevelResponse struct {
	// The lock information.
	ManagementLockObject
}

ManagementLocksClientGetAtResourceGroupLevelResponse contains the response from method ManagementLocksClient.GetAtResourceGroupLevel.

type ManagementLocksClientGetAtResourceLevelOptions added in v0.2.0

type ManagementLocksClientGetAtResourceLevelOptions struct {
}

ManagementLocksClientGetAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.GetAtResourceLevel method.

type ManagementLocksClientGetAtResourceLevelResponse added in v0.2.0

type ManagementLocksClientGetAtResourceLevelResponse struct {
	// The lock information.
	ManagementLockObject
}

ManagementLocksClientGetAtResourceLevelResponse contains the response from method ManagementLocksClient.GetAtResourceLevel.

type ManagementLocksClientGetAtSubscriptionLevelOptions added in v0.2.0

type ManagementLocksClientGetAtSubscriptionLevelOptions struct {
}

ManagementLocksClientGetAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.GetAtSubscriptionLevel method.

type ManagementLocksClientGetAtSubscriptionLevelResponse added in v0.2.0

type ManagementLocksClientGetAtSubscriptionLevelResponse struct {
	// The lock information.
	ManagementLockObject
}

ManagementLocksClientGetAtSubscriptionLevelResponse contains the response from method ManagementLocksClient.GetAtSubscriptionLevel.

type ManagementLocksClientGetByScopeOptions added in v0.2.0

type ManagementLocksClientGetByScopeOptions struct {
}

ManagementLocksClientGetByScopeOptions contains the optional parameters for the ManagementLocksClient.GetByScope method.

type ManagementLocksClientGetByScopeResponse added in v0.2.0

type ManagementLocksClientGetByScopeResponse struct {
	// The lock information.
	ManagementLockObject
}

ManagementLocksClientGetByScopeResponse contains the response from method ManagementLocksClient.GetByScope.

type ManagementLocksClientListAtResourceGroupLevelOptions added in v0.2.0

type ManagementLocksClientListAtResourceGroupLevelOptions struct {
	// The filter to apply on the operation.
	Filter *string
}

ManagementLocksClientListAtResourceGroupLevelOptions contains the optional parameters for the ManagementLocksClient.NewListAtResourceGroupLevelPager method.

type ManagementLocksClientListAtResourceGroupLevelResponse added in v0.2.0

type ManagementLocksClientListAtResourceGroupLevelResponse struct {
	// The list of locks.
	ManagementLockListResult
}

ManagementLocksClientListAtResourceGroupLevelResponse contains the response from method ManagementLocksClient.NewListAtResourceGroupLevelPager.

type ManagementLocksClientListAtResourceLevelOptions added in v0.2.0

type ManagementLocksClientListAtResourceLevelOptions struct {
	// The filter to apply on the operation.
	Filter *string
}

ManagementLocksClientListAtResourceLevelOptions contains the optional parameters for the ManagementLocksClient.NewListAtResourceLevelPager method.

type ManagementLocksClientListAtResourceLevelResponse added in v0.2.0

type ManagementLocksClientListAtResourceLevelResponse struct {
	// The list of locks.
	ManagementLockListResult
}

ManagementLocksClientListAtResourceLevelResponse contains the response from method ManagementLocksClient.NewListAtResourceLevelPager.

type ManagementLocksClientListAtSubscriptionLevelOptions added in v0.2.0

type ManagementLocksClientListAtSubscriptionLevelOptions struct {
	// The filter to apply on the operation.
	Filter *string
}

ManagementLocksClientListAtSubscriptionLevelOptions contains the optional parameters for the ManagementLocksClient.NewListAtSubscriptionLevelPager method.

type ManagementLocksClientListAtSubscriptionLevelResponse added in v0.2.0

type ManagementLocksClientListAtSubscriptionLevelResponse struct {
	// The list of locks.
	ManagementLockListResult
}

ManagementLocksClientListAtSubscriptionLevelResponse contains the response from method ManagementLocksClient.NewListAtSubscriptionLevelPager.

type ManagementLocksClientListByScopeOptions added in v0.2.0

type ManagementLocksClientListByScopeOptions struct {
	// The filter to apply on the operation.
	Filter *string
}

ManagementLocksClientListByScopeOptions contains the optional parameters for the ManagementLocksClient.NewListByScopePager method.

type ManagementLocksClientListByScopeResponse added in v0.2.0

type ManagementLocksClientListByScopeResponse struct {
	// The list of locks.
	ManagementLockListResult
}

ManagementLocksClientListByScopeResponse contains the response from method ManagementLocksClient.NewListByScopePager.

type Operation

type Operation struct {
	// The object that represents the operation.
	Display *OperationDisplay

	// Operation name: {provider}/{resource}/{operation}
	Name *string
}

Operation - Microsoft.Authorization operation

func (Operation) MarshalJSON added in v1.1.0

func (o Operation) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type Operation.

func (*Operation) UnmarshalJSON added in v1.1.0

func (o *Operation) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type Operation.

type OperationDisplay

type OperationDisplay struct {
	// Operation type: Read, write, delete, etc.
	Operation *string

	// Service provider: Microsoft.Authorization
	Provider *string

	// Resource on which the operation is performed: Profile, endpoint, etc.
	Resource *string
}

OperationDisplay - The object that represents the operation.

func (OperationDisplay) MarshalJSON added in v1.1.0

func (o OperationDisplay) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type OperationDisplay.

func (*OperationDisplay) UnmarshalJSON added in v1.1.0

func (o *OperationDisplay) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay.

type OperationListResult

type OperationListResult struct {
	// URL to get the next set of operation list results if there are any.
	NextLink *string

	// List of Microsoft.Authorization operations.
	Value []*Operation
}

OperationListResult - Result of the request to list Microsoft.Authorization operations. It contains a list of operations and a URL link to get the next set of results.

func (OperationListResult) MarshalJSON

func (o OperationListResult) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type OperationListResult.

func (*OperationListResult) UnmarshalJSON added in v1.1.0

func (o *OperationListResult) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult.

type SystemData

type SystemData struct {
	// The timestamp of resource creation (UTC).
	CreatedAt *time.Time

	// The identity that created the resource.
	CreatedBy *string

	// The type of identity that created the resource.
	CreatedByType *CreatedByType

	// The timestamp of resource last modification (UTC)
	LastModifiedAt *time.Time

	// The identity that last modified the resource.
	LastModifiedBy *string

	// The type of identity that last modified the resource.
	LastModifiedByType *CreatedByType
}

SystemData - Metadata pertaining to creation and last modification of the resource.

func (SystemData) MarshalJSON

func (s SystemData) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface for type SystemData.

func (*SystemData) UnmarshalJSON

func (s *SystemData) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface for type SystemData.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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