// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armstorage import ( "context" "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" "strings" ) // BlobContainersClient contains the methods for the BlobContainers group. // Don't use this type directly, use NewBlobContainersClient() instead. type BlobContainersClient struct { internal *arm.Client subscriptionID string } // NewBlobContainersClient creates a new instance of BlobContainersClient with the specified values. // - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - Contains optional client configuration. Pass nil to accept the default values. func NewBlobContainersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BlobContainersClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } client := &BlobContainersClient{ subscriptionID: subscriptionID, internal: cl, } return client, nil } // ClearLegalHold - Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold // clears out only the specified tags in the request. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - legalHold - The LegalHold property that will be clear from a blob container. // - options - BlobContainersClientClearLegalHoldOptions contains the optional parameters for the BlobContainersClient.ClearLegalHold // method. func (client *BlobContainersClient) ClearLegalHold(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold LegalHold, options *BlobContainersClientClearLegalHoldOptions) (BlobContainersClientClearLegalHoldResponse, error) { var err error const operationName = "BlobContainersClient.ClearLegalHold" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.clearLegalHoldCreateRequest(ctx, resourceGroupName, accountName, containerName, legalHold, options) if err != nil { return BlobContainersClientClearLegalHoldResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientClearLegalHoldResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return BlobContainersClientClearLegalHoldResponse{}, err } resp, err := client.clearLegalHoldHandleResponse(httpResp) return resp, err } // clearLegalHoldCreateRequest creates the ClearLegalHold request. func (client *BlobContainersClient) clearLegalHoldCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold LegalHold, _ *BlobContainersClientClearLegalHoldOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, legalHold); err != nil { return nil, err } return req, nil } // clearLegalHoldHandleResponse handles the ClearLegalHold response. func (client *BlobContainersClient) clearLegalHoldHandleResponse(resp *http.Response) (BlobContainersClientClearLegalHoldResponse, error) { result := BlobContainersClientClearLegalHoldResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.LegalHold); err != nil { return BlobContainersClientClearLegalHoldResponse{}, err } return result, nil } // Create - Creates a new container under the specified account as described by request body. The container resource includes // metadata and properties for that container. It does not include a list of the blobs contained by the container. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - blobContainer - Properties of the blob container to create. // - options - BlobContainersClientCreateOptions contains the optional parameters for the BlobContainersClient.Create method. func (client *BlobContainersClient) Create(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer BlobContainer, options *BlobContainersClientCreateOptions) (BlobContainersClientCreateResponse, error) { var err error const operationName = "BlobContainersClient.Create" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, containerName, blobContainer, options) if err != nil { return BlobContainersClientCreateResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientCreateResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) return BlobContainersClientCreateResponse{}, err } resp, err := client.createHandleResponse(httpResp) return resp, err } // createCreateRequest creates the Create request. func (client *BlobContainersClient) createCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer BlobContainer, _ *BlobContainersClientCreateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, blobContainer); err != nil { return nil, err } return req, nil } // createHandleResponse handles the Create response. func (client *BlobContainersClient) createHandleResponse(resp *http.Response) (BlobContainersClientCreateResponse, error) { result := BlobContainersClientCreateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.BlobContainer); err != nil { return BlobContainersClientCreateResponse{}, err } return result, nil } // CreateOrUpdateImmutabilityPolicy - Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given // but not required for this operation. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - parameters - The ImmutabilityPolicy Properties that will be created or updated to a blob container. // - options - BlobContainersClientCreateOrUpdateImmutabilityPolicyOptions contains the optional parameters for the BlobContainersClient.CreateOrUpdateImmutabilityPolicy // method. func (client *BlobContainersClient) CreateOrUpdateImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, parameters ImmutabilityPolicy, options *BlobContainersClientCreateOrUpdateImmutabilityPolicyOptions) (BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse, error) { var err error const operationName = "BlobContainersClient.CreateOrUpdateImmutabilityPolicy" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.createOrUpdateImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, parameters, options) if err != nil { return BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse{}, err } resp, err := client.createOrUpdateImmutabilityPolicyHandleResponse(httpResp) return resp, err } // createOrUpdateImmutabilityPolicyCreateRequest creates the CreateOrUpdateImmutabilityPolicy request. func (client *BlobContainersClient) createOrUpdateImmutabilityPolicyCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, parameters ImmutabilityPolicy, options *BlobContainersClientCreateOrUpdateImmutabilityPolicyOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } return req, nil } // createOrUpdateImmutabilityPolicyHandleResponse handles the CreateOrUpdateImmutabilityPolicy response. func (client *BlobContainersClient) createOrUpdateImmutabilityPolicyHandleResponse(resp *http.Response) (BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse, error) { result := BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse{} if val := resp.Header.Get("ETag"); val != "" { result.ETag = &val } if err := runtime.UnmarshalAsJSON(resp, &result.ImmutabilityPolicy); err != nil { return BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse{}, err } return result, nil } // Delete - Deletes specified container under its account. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - options - BlobContainersClientDeleteOptions contains the optional parameters for the BlobContainersClient.Delete method. func (client *BlobContainersClient) Delete(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientDeleteOptions) (BlobContainersClientDeleteResponse, error) { var err error const operationName = "BlobContainersClient.Delete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { return BlobContainersClientDeleteResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientDeleteResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return BlobContainersClientDeleteResponse{}, err } return BlobContainersClientDeleteResponse{}, nil } // deleteCreateRequest creates the Delete request. func (client *BlobContainersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, _ *BlobContainersClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() return req, nil } // DeleteImmutabilityPolicy - Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays // set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only // way is to delete the container after deleting all expired blobs inside the policy locked container. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - ifMatch - The entity state (ETag) version of the immutability policy to update must be returned to the server for all update // operations. The ETag value must include the leading and trailing double quotes as returned by the service. // - options - BlobContainersClientDeleteImmutabilityPolicyOptions contains the optional parameters for the BlobContainersClient.DeleteImmutabilityPolicy // method. func (client *BlobContainersClient) DeleteImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersClientDeleteImmutabilityPolicyOptions) (BlobContainersClientDeleteImmutabilityPolicyResponse, error) { var err error const operationName = "BlobContainersClient.DeleteImmutabilityPolicy" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.deleteImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, ifMatch, options) if err != nil { return BlobContainersClientDeleteImmutabilityPolicyResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientDeleteImmutabilityPolicyResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return BlobContainersClientDeleteImmutabilityPolicyResponse{}, err } resp, err := client.deleteImmutabilityPolicyHandleResponse(httpResp) return resp, err } // deleteImmutabilityPolicyCreateRequest creates the DeleteImmutabilityPolicy request. func (client *BlobContainersClient) deleteImmutabilityPolicyCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, _ *BlobContainersClientDeleteImmutabilityPolicyOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // deleteImmutabilityPolicyHandleResponse handles the DeleteImmutabilityPolicy response. func (client *BlobContainersClient) deleteImmutabilityPolicyHandleResponse(resp *http.Response) (BlobContainersClientDeleteImmutabilityPolicyResponse, error) { result := BlobContainersClientDeleteImmutabilityPolicyResponse{} if val := resp.Header.Get("ETag"); val != "" { result.ETag = &val } if err := runtime.UnmarshalAsJSON(resp, &result.ImmutabilityPolicy); err != nil { return BlobContainersClientDeleteImmutabilityPolicyResponse{}, err } return result, nil } // ExtendImmutabilityPolicy - Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action // allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - ifMatch - The entity state (ETag) version of the immutability policy to update must be returned to the server for all update // operations. The ETag value must include the leading and trailing double quotes as returned by the service. // - options - BlobContainersClientExtendImmutabilityPolicyOptions contains the optional parameters for the BlobContainersClient.ExtendImmutabilityPolicy // method. func (client *BlobContainersClient) ExtendImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersClientExtendImmutabilityPolicyOptions) (BlobContainersClientExtendImmutabilityPolicyResponse, error) { var err error const operationName = "BlobContainersClient.ExtendImmutabilityPolicy" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.extendImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, ifMatch, options) if err != nil { return BlobContainersClientExtendImmutabilityPolicyResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientExtendImmutabilityPolicyResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return BlobContainersClientExtendImmutabilityPolicyResponse{}, err } resp, err := client.extendImmutabilityPolicyHandleResponse(httpResp) return resp, err } // extendImmutabilityPolicyCreateRequest creates the ExtendImmutabilityPolicy request. func (client *BlobContainersClient) extendImmutabilityPolicyCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersClientExtendImmutabilityPolicyOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["If-Match"] = []string{ifMatch} if options != nil && options.Parameters != nil { req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, *options.Parameters); err != nil { return nil, err } return req, nil } return req, nil } // extendImmutabilityPolicyHandleResponse handles the ExtendImmutabilityPolicy response. func (client *BlobContainersClient) extendImmutabilityPolicyHandleResponse(resp *http.Response) (BlobContainersClientExtendImmutabilityPolicyResponse, error) { result := BlobContainersClientExtendImmutabilityPolicyResponse{} if val := resp.Header.Get("ETag"); val != "" { result.ETag = &val } if err := runtime.UnmarshalAsJSON(resp, &result.ImmutabilityPolicy); err != nil { return BlobContainersClientExtendImmutabilityPolicyResponse{}, err } return result, nil } // Get - Gets properties of a specified container. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - options - BlobContainersClientGetOptions contains the optional parameters for the BlobContainersClient.Get method. func (client *BlobContainersClient) Get(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientGetOptions) (BlobContainersClientGetResponse, error) { var err error const operationName = "BlobContainersClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { return BlobContainersClientGetResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientGetResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return BlobContainersClientGetResponse{}, err } resp, err := client.getHandleResponse(httpResp) return resp, err } // getCreateRequest creates the Get request. func (client *BlobContainersClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, _ *BlobContainersClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // getHandleResponse handles the Get response. func (client *BlobContainersClient) getHandleResponse(resp *http.Response) (BlobContainersClientGetResponse, error) { result := BlobContainersClientGetResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.BlobContainer); err != nil { return BlobContainersClientGetResponse{}, err } return result, nil } // GetImmutabilityPolicy - Gets the existing immutability policy along with the corresponding ETag in response headers and // body. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - options - BlobContainersClientGetImmutabilityPolicyOptions contains the optional parameters for the BlobContainersClient.GetImmutabilityPolicy // method. func (client *BlobContainersClient) GetImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientGetImmutabilityPolicyOptions) (BlobContainersClientGetImmutabilityPolicyResponse, error) { var err error const operationName = "BlobContainersClient.GetImmutabilityPolicy" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.getImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { return BlobContainersClientGetImmutabilityPolicyResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientGetImmutabilityPolicyResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return BlobContainersClientGetImmutabilityPolicyResponse{}, err } resp, err := client.getImmutabilityPolicyHandleResponse(httpResp) return resp, err } // getImmutabilityPolicyCreateRequest creates the GetImmutabilityPolicy request. func (client *BlobContainersClient) getImmutabilityPolicyCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientGetImmutabilityPolicyOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } return req, nil } // getImmutabilityPolicyHandleResponse handles the GetImmutabilityPolicy response. func (client *BlobContainersClient) getImmutabilityPolicyHandleResponse(resp *http.Response) (BlobContainersClientGetImmutabilityPolicyResponse, error) { result := BlobContainersClientGetImmutabilityPolicyResponse{} if val := resp.Header.Get("ETag"); val != "" { result.ETag = &val } if err := runtime.UnmarshalAsJSON(resp, &result.ImmutabilityPolicy); err != nil { return BlobContainersClientGetImmutabilityPolicyResponse{}, err } return result, nil } // Lease - The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration // can be 15 to 60 seconds, or can be infinite. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - options - BlobContainersClientLeaseOptions contains the optional parameters for the BlobContainersClient.Lease method. func (client *BlobContainersClient) Lease(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientLeaseOptions) (BlobContainersClientLeaseResponse, error) { var err error const operationName = "BlobContainersClient.Lease" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.leaseCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { return BlobContainersClientLeaseResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientLeaseResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return BlobContainersClientLeaseResponse{}, err } resp, err := client.leaseHandleResponse(httpResp) return resp, err } // leaseCreateRequest creates the Lease request. func (client *BlobContainersClient) leaseCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientLeaseOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Parameters != nil { req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, *options.Parameters); err != nil { return nil, err } return req, nil } return req, nil } // leaseHandleResponse handles the Lease response. func (client *BlobContainersClient) leaseHandleResponse(resp *http.Response) (BlobContainersClientLeaseResponse, error) { result := BlobContainersClientLeaseResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.LeaseContainerResponse); err != nil { return BlobContainersClientLeaseResponse{}, err } return result, nil } // NewListPager - Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation // token. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - options - BlobContainersClientListOptions contains the optional parameters for the BlobContainersClient.NewListPager method. func (client *BlobContainersClient) NewListPager(resourceGroupName string, accountName string, options *BlobContainersClientListOptions) *runtime.Pager[BlobContainersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[BlobContainersClientListResponse]{ More: func(page BlobContainersClientListResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *BlobContainersClientListResponse) (BlobContainersClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BlobContainersClient.NewListPager") nextLink := "" if page != nil { nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { return client.listCreateRequest(ctx, resourceGroupName, accountName, options) }, nil) if err != nil { return BlobContainersClientListResponse{}, err } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), }) } // listCreateRequest creates the List request. func (client *BlobContainersClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *BlobContainersClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } if options != nil && options.Include != nil { reqQP.Set("$include", string(*options.Include)) } if options != nil && options.Maxpagesize != nil { reqQP.Set("$maxpagesize", *options.Maxpagesize) } reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // listHandleResponse handles the List response. func (client *BlobContainersClient) listHandleResponse(resp *http.Response) (BlobContainersClientListResponse, error) { result := BlobContainersClientListResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ListContainerItems); err != nil { return BlobContainersClientListResponse{}, err } return result, nil } // LockImmutabilityPolicy - Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy // action. ETag in If-Match is required for this operation. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - ifMatch - The entity state (ETag) version of the immutability policy to update must be returned to the server for all update // operations. The ETag value must include the leading and trailing double quotes as returned by the service. // - options - BlobContainersClientLockImmutabilityPolicyOptions contains the optional parameters for the BlobContainersClient.LockImmutabilityPolicy // method. func (client *BlobContainersClient) LockImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersClientLockImmutabilityPolicyOptions) (BlobContainersClientLockImmutabilityPolicyResponse, error) { var err error const operationName = "BlobContainersClient.LockImmutabilityPolicy" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.lockImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, ifMatch, options) if err != nil { return BlobContainersClientLockImmutabilityPolicyResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientLockImmutabilityPolicyResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return BlobContainersClientLockImmutabilityPolicyResponse{}, err } resp, err := client.lockImmutabilityPolicyHandleResponse(httpResp) return resp, err } // lockImmutabilityPolicyCreateRequest creates the LockImmutabilityPolicy request. func (client *BlobContainersClient) lockImmutabilityPolicyCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, _ *BlobContainersClientLockImmutabilityPolicyOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["If-Match"] = []string{ifMatch} return req, nil } // lockImmutabilityPolicyHandleResponse handles the LockImmutabilityPolicy response. func (client *BlobContainersClient) lockImmutabilityPolicyHandleResponse(resp *http.Response) (BlobContainersClientLockImmutabilityPolicyResponse, error) { result := BlobContainersClientLockImmutabilityPolicyResponse{} if val := resp.Header.Get("ETag"); val != "" { result.ETag = &val } if err := runtime.UnmarshalAsJSON(resp, &result.ImmutabilityPolicy); err != nil { return BlobContainersClientLockImmutabilityPolicyResponse{}, err } return result, nil } // BeginObjectLevelWorm - This operation migrates a blob container from container level WORM to object level immutability // enabled container. Prerequisites require a container level immutability policy either in locked or unlocked state, Account // level versioning must be enabled and there should be no Legal hold on the container. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - options - BlobContainersClientBeginObjectLevelWormOptions contains the optional parameters for the BlobContainersClient.BeginObjectLevelWorm // method. func (client *BlobContainersClient) BeginObjectLevelWorm(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientBeginObjectLevelWormOptions) (*runtime.Poller[BlobContainersClientObjectLevelWormResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.objectLevelWorm(ctx, resourceGroupName, accountName, containerName, options) if err != nil { return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BlobContainersClientObjectLevelWormResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BlobContainersClientObjectLevelWormResponse]{ Tracer: client.internal.Tracer(), }) } } // ObjectLevelWorm - This operation migrates a blob container from container level WORM to object level immutability enabled // container. Prerequisites require a container level immutability policy either in locked or unlocked state, Account level // versioning must be enabled and there should be no Legal hold on the container. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 func (client *BlobContainersClient) objectLevelWorm(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientBeginObjectLevelWormOptions) (*http.Response, error) { var err error const operationName = "BlobContainersClient.BeginObjectLevelWorm" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.objectLevelWormCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } return httpResp, nil } // objectLevelWormCreateRequest creates the ObjectLevelWorm request. func (client *BlobContainersClient) objectLevelWormCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, _ *BlobContainersClientBeginObjectLevelWormOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() return req, nil } // SetLegalHold - Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append // pattern and does not clear out the existing tags that are not specified in the request. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - legalHold - The LegalHold property that will be set to a blob container. // - options - BlobContainersClientSetLegalHoldOptions contains the optional parameters for the BlobContainersClient.SetLegalHold // method. func (client *BlobContainersClient) SetLegalHold(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold LegalHold, options *BlobContainersClientSetLegalHoldOptions) (BlobContainersClientSetLegalHoldResponse, error) { var err error const operationName = "BlobContainersClient.SetLegalHold" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.setLegalHoldCreateRequest(ctx, resourceGroupName, accountName, containerName, legalHold, options) if err != nil { return BlobContainersClientSetLegalHoldResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientSetLegalHoldResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return BlobContainersClientSetLegalHoldResponse{}, err } resp, err := client.setLegalHoldHandleResponse(httpResp) return resp, err } // setLegalHoldCreateRequest creates the SetLegalHold request. func (client *BlobContainersClient) setLegalHoldCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold LegalHold, _ *BlobContainersClientSetLegalHoldOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, legalHold); err != nil { return nil, err } return req, nil } // setLegalHoldHandleResponse handles the SetLegalHold response. func (client *BlobContainersClient) setLegalHoldHandleResponse(resp *http.Response) (BlobContainersClientSetLegalHoldResponse, error) { result := BlobContainersClientSetLegalHoldResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.LegalHold); err != nil { return BlobContainersClientSetLegalHoldResponse{}, err } return result, nil } // Update - Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. // Update fails if the specified container doesn't already exist. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2025-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of the storage account within the specified resource group. Storage account names must be between // 3 and 24 characters in length and use numbers and lower-case letters only. // - containerName - The name of the blob container within the specified storage account. Blob container names must be between // 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately // preceded and followed by a letter or number. // - blobContainer - Properties to update for the blob container. // - options - BlobContainersClientUpdateOptions contains the optional parameters for the BlobContainersClient.Update method. func (client *BlobContainersClient) Update(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer BlobContainer, options *BlobContainersClientUpdateOptions) (BlobContainersClientUpdateResponse, error) { var err error const operationName = "BlobContainersClient.Update" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, containerName, blobContainer, options) if err != nil { return BlobContainersClientUpdateResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientUpdateResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return BlobContainersClientUpdateResponse{}, err } resp, err := client.updateHandleResponse(httpResp) return resp, err } // updateCreateRequest creates the Update request. func (client *BlobContainersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer BlobContainer, _ *BlobContainersClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if accountName == "" { return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) if containerName == "" { return nil, errors.New("parameter containerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2025-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, blobContainer); err != nil { return nil, err } return req, nil } // updateHandleResponse handles the Update response. func (client *BlobContainersClient) updateHandleResponse(resp *http.Response) (BlobContainersClientUpdateResponse, error) { result := BlobContainersClientUpdateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.BlobContainer); err != nil { return BlobContainersClientUpdateResponse{}, err } return result, nil }