From 26c5c062afb74372e4423558081764af5797615c Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Tue, 27 Dec 2022 13:17:09 -0800 Subject: [PATCH 01/17] first generation --- sdk/storage/azqueue/generated/zz_constants.go | 155 ++++++ .../azqueue/generated/zz_messageid_client.go | 202 ++++++++ .../azqueue/generated/zz_messages_client.go | 323 ++++++++++++ sdk/storage/azqueue/generated/zz_models.go | 425 ++++++++++++++++ .../azqueue/generated/zz_models_serde.go | 282 +++++++++++ .../azqueue/generated/zz_queue_client.go | 460 ++++++++++++++++++ .../azqueue/generated/zz_response_types.go | 226 +++++++++ .../azqueue/generated/zz_service_client.go | 301 ++++++++++++ .../azqueue/generated/zz_time_rfc1123.go | 47 ++ .../azqueue/generated/zz_time_rfc3339.go | 63 +++ .../azqueue/generated/zz_xml_helper.go | 42 ++ sdk/storage/azqueue/internal/autorest.md | 23 + 12 files changed, 2549 insertions(+) create mode 100644 sdk/storage/azqueue/generated/zz_constants.go create mode 100644 sdk/storage/azqueue/generated/zz_messageid_client.go create mode 100644 sdk/storage/azqueue/generated/zz_messages_client.go create mode 100644 sdk/storage/azqueue/generated/zz_models.go create mode 100644 sdk/storage/azqueue/generated/zz_models_serde.go create mode 100644 sdk/storage/azqueue/generated/zz_queue_client.go create mode 100644 sdk/storage/azqueue/generated/zz_response_types.go create mode 100644 sdk/storage/azqueue/generated/zz_service_client.go create mode 100644 sdk/storage/azqueue/generated/zz_time_rfc1123.go create mode 100644 sdk/storage/azqueue/generated/zz_time_rfc3339.go create mode 100644 sdk/storage/azqueue/generated/zz_xml_helper.go create mode 100644 sdk/storage/azqueue/internal/autorest.md diff --git a/sdk/storage/azqueue/generated/zz_constants.go b/sdk/storage/azqueue/generated/zz_constants.go new file mode 100644 index 000000000000..a680dbaafecb --- /dev/null +++ b/sdk/storage/azqueue/generated/zz_constants.go @@ -0,0 +1,155 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package generated + +// GeoReplicationStatusType - The status of the secondary location +type GeoReplicationStatusType string + +const ( + GeoReplicationStatusTypeBootstrap GeoReplicationStatusType = "bootstrap" + GeoReplicationStatusTypeLive GeoReplicationStatusType = "live" + GeoReplicationStatusTypeUnavailable GeoReplicationStatusType = "unavailable" +) + +// PossibleGeoReplicationStatusTypeValues returns the possible values for the GeoReplicationStatusType const type. +func PossibleGeoReplicationStatusTypeValues() []GeoReplicationStatusType { + return []GeoReplicationStatusType{ + GeoReplicationStatusTypeBootstrap, + GeoReplicationStatusTypeLive, + GeoReplicationStatusTypeUnavailable, + } +} + +// StorageErrorCode - Error codes returned by the service +type StorageErrorCode string + +const ( + StorageErrorCodeAccountAlreadyExists StorageErrorCode = "AccountAlreadyExists" + StorageErrorCodeAccountBeingCreated StorageErrorCode = "AccountBeingCreated" + StorageErrorCodeAccountIsDisabled StorageErrorCode = "AccountIsDisabled" + StorageErrorCodeAuthenticationFailed StorageErrorCode = "AuthenticationFailed" + StorageErrorCodeAuthorizationFailure StorageErrorCode = "AuthorizationFailure" + StorageErrorCodeAuthorizationPermissionMismatch StorageErrorCode = "AuthorizationPermissionMismatch" + StorageErrorCodeAuthorizationProtocolMismatch StorageErrorCode = "AuthorizationProtocolMismatch" + StorageErrorCodeAuthorizationResourceTypeMismatch StorageErrorCode = "AuthorizationResourceTypeMismatch" + StorageErrorCodeAuthorizationServiceMismatch StorageErrorCode = "AuthorizationServiceMismatch" + StorageErrorCodeAuthorizationSourceIPMismatch StorageErrorCode = "AuthorizationSourceIPMismatch" + StorageErrorCodeConditionHeadersNotSupported StorageErrorCode = "ConditionHeadersNotSupported" + StorageErrorCodeConditionNotMet StorageErrorCode = "ConditionNotMet" + StorageErrorCodeEmptyMetadataKey StorageErrorCode = "EmptyMetadataKey" + StorageErrorCodeFeatureVersionMismatch StorageErrorCode = "FeatureVersionMismatch" + StorageErrorCodeInsufficientAccountPermissions StorageErrorCode = "InsufficientAccountPermissions" + StorageErrorCodeInternalError StorageErrorCode = "InternalError" + StorageErrorCodeInvalidAuthenticationInfo StorageErrorCode = "InvalidAuthenticationInfo" + StorageErrorCodeInvalidHTTPVerb StorageErrorCode = "InvalidHttpVerb" + StorageErrorCodeInvalidHeaderValue StorageErrorCode = "InvalidHeaderValue" + StorageErrorCodeInvalidInput StorageErrorCode = "InvalidInput" + StorageErrorCodeInvalidMD5 StorageErrorCode = "InvalidMd5" + StorageErrorCodeInvalidMarker StorageErrorCode = "InvalidMarker" + StorageErrorCodeInvalidMetadata StorageErrorCode = "InvalidMetadata" + StorageErrorCodeInvalidQueryParameterValue StorageErrorCode = "InvalidQueryParameterValue" + StorageErrorCodeInvalidRange StorageErrorCode = "InvalidRange" + StorageErrorCodeInvalidResourceName StorageErrorCode = "InvalidResourceName" + StorageErrorCodeInvalidURI StorageErrorCode = "InvalidUri" + StorageErrorCodeInvalidXMLDocument StorageErrorCode = "InvalidXmlDocument" + StorageErrorCodeInvalidXMLNodeValue StorageErrorCode = "InvalidXmlNodeValue" + StorageErrorCodeMD5Mismatch StorageErrorCode = "Md5Mismatch" + StorageErrorCodeMessageNotFound StorageErrorCode = "MessageNotFound" + StorageErrorCodeMessageTooLarge StorageErrorCode = "MessageTooLarge" + StorageErrorCodeMetadataTooLarge StorageErrorCode = "MetadataTooLarge" + StorageErrorCodeMissingContentLengthHeader StorageErrorCode = "MissingContentLengthHeader" + StorageErrorCodeMissingRequiredHeader StorageErrorCode = "MissingRequiredHeader" + StorageErrorCodeMissingRequiredQueryParameter StorageErrorCode = "MissingRequiredQueryParameter" + StorageErrorCodeMissingRequiredXMLNode StorageErrorCode = "MissingRequiredXmlNode" + StorageErrorCodeMultipleConditionHeadersNotSupported StorageErrorCode = "MultipleConditionHeadersNotSupported" + StorageErrorCodeOperationTimedOut StorageErrorCode = "OperationTimedOut" + StorageErrorCodeOutOfRangeInput StorageErrorCode = "OutOfRangeInput" + StorageErrorCodeOutOfRangeQueryParameterValue StorageErrorCode = "OutOfRangeQueryParameterValue" + StorageErrorCodePopReceiptMismatch StorageErrorCode = "PopReceiptMismatch" + StorageErrorCodeQueueAlreadyExists StorageErrorCode = "QueueAlreadyExists" + StorageErrorCodeQueueBeingDeleted StorageErrorCode = "QueueBeingDeleted" + StorageErrorCodeQueueDisabled StorageErrorCode = "QueueDisabled" + StorageErrorCodeQueueNotEmpty StorageErrorCode = "QueueNotEmpty" + StorageErrorCodeQueueNotFound StorageErrorCode = "QueueNotFound" + StorageErrorCodeRequestBodyTooLarge StorageErrorCode = "RequestBodyTooLarge" + StorageErrorCodeRequestURLFailedToParse StorageErrorCode = "RequestUrlFailedToParse" + StorageErrorCodeResourceAlreadyExists StorageErrorCode = "ResourceAlreadyExists" + StorageErrorCodeResourceNotFound StorageErrorCode = "ResourceNotFound" + StorageErrorCodeResourceTypeMismatch StorageErrorCode = "ResourceTypeMismatch" + StorageErrorCodeServerBusy StorageErrorCode = "ServerBusy" + StorageErrorCodeUnsupportedHTTPVerb StorageErrorCode = "UnsupportedHttpVerb" + StorageErrorCodeUnsupportedHeader StorageErrorCode = "UnsupportedHeader" + StorageErrorCodeUnsupportedQueryParameter StorageErrorCode = "UnsupportedQueryParameter" + StorageErrorCodeUnsupportedXMLNode StorageErrorCode = "UnsupportedXmlNode" +) + +// PossibleStorageErrorCodeValues returns the possible values for the StorageErrorCode const type. +func PossibleStorageErrorCodeValues() []StorageErrorCode { + return []StorageErrorCode{ + StorageErrorCodeAccountAlreadyExists, + StorageErrorCodeAccountBeingCreated, + StorageErrorCodeAccountIsDisabled, + StorageErrorCodeAuthenticationFailed, + StorageErrorCodeAuthorizationFailure, + StorageErrorCodeAuthorizationPermissionMismatch, + StorageErrorCodeAuthorizationProtocolMismatch, + StorageErrorCodeAuthorizationResourceTypeMismatch, + StorageErrorCodeAuthorizationServiceMismatch, + StorageErrorCodeAuthorizationSourceIPMismatch, + StorageErrorCodeConditionHeadersNotSupported, + StorageErrorCodeConditionNotMet, + StorageErrorCodeEmptyMetadataKey, + StorageErrorCodeFeatureVersionMismatch, + StorageErrorCodeInsufficientAccountPermissions, + StorageErrorCodeInternalError, + StorageErrorCodeInvalidAuthenticationInfo, + StorageErrorCodeInvalidHTTPVerb, + StorageErrorCodeInvalidHeaderValue, + StorageErrorCodeInvalidInput, + StorageErrorCodeInvalidMD5, + StorageErrorCodeInvalidMarker, + StorageErrorCodeInvalidMetadata, + StorageErrorCodeInvalidQueryParameterValue, + StorageErrorCodeInvalidRange, + StorageErrorCodeInvalidResourceName, + StorageErrorCodeInvalidURI, + StorageErrorCodeInvalidXMLDocument, + StorageErrorCodeInvalidXMLNodeValue, + StorageErrorCodeMD5Mismatch, + StorageErrorCodeMessageNotFound, + StorageErrorCodeMessageTooLarge, + StorageErrorCodeMetadataTooLarge, + StorageErrorCodeMissingContentLengthHeader, + StorageErrorCodeMissingRequiredHeader, + StorageErrorCodeMissingRequiredQueryParameter, + StorageErrorCodeMissingRequiredXMLNode, + StorageErrorCodeMultipleConditionHeadersNotSupported, + StorageErrorCodeOperationTimedOut, + StorageErrorCodeOutOfRangeInput, + StorageErrorCodeOutOfRangeQueryParameterValue, + StorageErrorCodePopReceiptMismatch, + StorageErrorCodeQueueAlreadyExists, + StorageErrorCodeQueueBeingDeleted, + StorageErrorCodeQueueDisabled, + StorageErrorCodeQueueNotEmpty, + StorageErrorCodeQueueNotFound, + StorageErrorCodeRequestBodyTooLarge, + StorageErrorCodeRequestURLFailedToParse, + StorageErrorCodeResourceAlreadyExists, + StorageErrorCodeResourceNotFound, + StorageErrorCodeResourceTypeMismatch, + StorageErrorCodeServerBusy, + StorageErrorCodeUnsupportedHTTPVerb, + StorageErrorCodeUnsupportedHeader, + StorageErrorCodeUnsupportedQueryParameter, + StorageErrorCodeUnsupportedXMLNode, + } +} + diff --git a/sdk/storage/azqueue/generated/zz_messageid_client.go b/sdk/storage/azqueue/generated/zz_messageid_client.go new file mode 100644 index 000000000000..17c64f93251e --- /dev/null +++ b/sdk/storage/azqueue/generated/zz_messageid_client.go @@ -0,0 +1,202 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package generated + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// MessageIDClient contains the methods for the MessageID group. +// Don't use this type directly, use NewMessageIDClient() instead. +type MessageIDClient struct { + endpoint string + pl runtime.Pipeline +} + +// NewMessageIDClient creates a new instance of MessageIDClient with the specified values. +// endpoint - The URL of the service account, queue or message that is the target of the desired operation. +// pl - the pipeline used for sending requests and handling responses. +func NewMessageIDClient(endpoint string, pl runtime.Pipeline) *MessageIDClient { + client := &MessageIDClient{ + endpoint: endpoint, + pl: pl, + } + return client +} + +// Delete - The Delete operation deletes the specified message. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// queueName - The queue name. +// messageid - The container name. +// popReceipt - Required. Specifies the valid pop receipt value returned from an earlier call to the Get Messages or Update +// Message operation. +// options - MessageIDClientDeleteOptions contains the optional parameters for the MessageIDClient.Delete method. +func (client *MessageIDClient) Delete(ctx context.Context, queueName string, messageid string, popReceipt string, options *MessageIDClientDeleteOptions) (MessageIDClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, queueName, messageid, popReceipt, options) + if err != nil { + return MessageIDClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MessageIDClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusNoContent) { + return MessageIDClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return client.deleteHandleResponse(resp) +} + +// deleteCreateRequest creates the Delete request. +func (client *MessageIDClient) deleteCreateRequest(ctx context.Context, queueName string, messageid string, popReceipt string, options *MessageIDClientDeleteOptions) (*policy.Request, error) { + urlPath := "/{queueName}/messages/{messageid}" + if queueName == "" { + return nil, errors.New("parameter queueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) + if messageid == "" { + return nil, errors.New("parameter messageid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{messageid}", url.PathEscape(messageid)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("popreceipt", popReceipt) + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// deleteHandleResponse handles the Delete response. +func (client *MessageIDClient) deleteHandleResponse(resp *http.Response) (MessageIDClientDeleteResponse, error) { + result := MessageIDClientDeleteResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return MessageIDClientDeleteResponse{}, err + } + result.Date = &date + } + return result, nil +} + +// Update - The Update operation was introduced with version 2011-08-18 of the Queue service API. The Update Message operation +// updates the visibility timeout of a message. You can also use this operation to +// update the contents of a message. A message must be in a format that can be included in an XML request with UTF-8 encoding, +// and the encoded message can be up to 64KB in size. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// queueName - The queue name. +// messageid - The container name. +// popReceipt - Required. Specifies the valid pop receipt value returned from an earlier call to the Get Messages or Update +// Message operation. +// visibilitytimeout - Optional. Specifies the new visibility timeout value, in seconds, relative to server time. The default +// value is 30 seconds. A specified value must be larger than or equal to 1 second, and cannot be +// larger than 7 days, or larger than 2 hours on REST protocol versions prior to version 2011-08-18. The visibility timeout +// of a message can be set to a value later than the expiry time. +// queueMessage - A Message object which can be stored in a Queue +// options - MessageIDClientUpdateOptions contains the optional parameters for the MessageIDClient.Update method. +func (client *MessageIDClient) Update(ctx context.Context, queueName string, messageid string, popReceipt string, visibilitytimeout int32, queueMessage QueueMessage, options *MessageIDClientUpdateOptions) (MessageIDClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, queueName, messageid, popReceipt, visibilitytimeout, queueMessage, options) + if err != nil { + return MessageIDClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MessageIDClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusNoContent) { + return MessageIDClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *MessageIDClient) updateCreateRequest(ctx context.Context, queueName string, messageid string, popReceipt string, visibilitytimeout int32, queueMessage QueueMessage, options *MessageIDClientUpdateOptions) (*policy.Request, error) { + urlPath := "/{queueName}/messages/{messageid}" + if queueName == "" { + return nil, errors.New("parameter queueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) + if messageid == "" { + return nil, errors.New("parameter messageid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{messageid}", url.PathEscape(messageid)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("popreceipt", popReceipt) + reqQP.Set("visibilitytimeout", strconv.FormatInt(int64(visibilitytimeout), 10)) + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, runtime.MarshalAsXML(req, queueMessage) +} + +// updateHandleResponse handles the Update response. +func (client *MessageIDClient) updateHandleResponse(resp *http.Response) (MessageIDClientUpdateResponse, error) { + result := MessageIDClientUpdateResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return MessageIDClientUpdateResponse{}, err + } + result.Date = &date + } + if val := resp.Header.Get("x-ms-popreceipt"); val != "" { + result.PopReceipt = &val + } + if val := resp.Header.Get("x-ms-time-next-visible"); val != "" { + timeNextVisible, err := time.Parse(time.RFC1123, val) + if err != nil { + return MessageIDClientUpdateResponse{}, err + } + result.TimeNextVisible = &timeNextVisible + } + return result, nil +} + diff --git a/sdk/storage/azqueue/generated/zz_messages_client.go b/sdk/storage/azqueue/generated/zz_messages_client.go new file mode 100644 index 000000000000..0fc3331572e1 --- /dev/null +++ b/sdk/storage/azqueue/generated/zz_messages_client.go @@ -0,0 +1,323 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package generated + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// MessagesClient contains the methods for the Messages group. +// Don't use this type directly, use NewMessagesClient() instead. +type MessagesClient struct { + endpoint string + pl runtime.Pipeline +} + +// NewMessagesClient creates a new instance of MessagesClient with the specified values. +// endpoint - The URL of the service account, queue or message that is the target of the desired operation. +// pl - the pipeline used for sending requests and handling responses. +func NewMessagesClient(endpoint string, pl runtime.Pipeline) *MessagesClient { + client := &MessagesClient{ + endpoint: endpoint, + pl: pl, + } + return client +} + +// Clear - The Clear operation deletes all messages from the specified queue. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// queueName - The queue name. +// options - MessagesClientClearOptions contains the optional parameters for the MessagesClient.Clear method. +func (client *MessagesClient) Clear(ctx context.Context, queueName string, options *MessagesClientClearOptions) (MessagesClientClearResponse, error) { + req, err := client.clearCreateRequest(ctx, queueName, options) + if err != nil { + return MessagesClientClearResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MessagesClientClearResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusNoContent) { + return MessagesClientClearResponse{}, runtime.NewResponseError(resp) + } + return client.clearHandleResponse(resp) +} + +// clearCreateRequest creates the Clear request. +func (client *MessagesClient) clearCreateRequest(ctx context.Context, queueName string, options *MessagesClientClearOptions) (*policy.Request, error) { + urlPath := "/{queueName}/messages" + if queueName == "" { + return nil, errors.New("parameter queueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// clearHandleResponse handles the Clear response. +func (client *MessagesClient) clearHandleResponse(resp *http.Response) (MessagesClientClearResponse, error) { + result := MessagesClientClearResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return MessagesClientClearResponse{}, err + } + result.Date = &date + } + return result, nil +} + +// Dequeue - The Dequeue operation retrieves one or more messages from the front of the queue. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// queueName - The queue name. +// options - MessagesClientDequeueOptions contains the optional parameters for the MessagesClient.Dequeue method. +func (client *MessagesClient) Dequeue(ctx context.Context, queueName string, options *MessagesClientDequeueOptions) (MessagesClientDequeueResponse, error) { + req, err := client.dequeueCreateRequest(ctx, queueName, options) + if err != nil { + return MessagesClientDequeueResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MessagesClientDequeueResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MessagesClientDequeueResponse{}, runtime.NewResponseError(resp) + } + return client.dequeueHandleResponse(resp) +} + +// dequeueCreateRequest creates the Dequeue request. +func (client *MessagesClient) dequeueCreateRequest(ctx context.Context, queueName string, options *MessagesClientDequeueOptions) (*policy.Request, error) { + urlPath := "/{queueName}/messages" + if queueName == "" { + return nil, errors.New("parameter queueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.NumberOfMessages != nil { + reqQP.Set("numofmessages", strconv.FormatInt(int64(*options.NumberOfMessages), 10)) + } + if options != nil && options.Visibilitytimeout != nil { + reqQP.Set("visibilitytimeout", strconv.FormatInt(int64(*options.Visibilitytimeout), 10)) + } + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// dequeueHandleResponse handles the Dequeue response. +func (client *MessagesClient) dequeueHandleResponse(resp *http.Response) (MessagesClientDequeueResponse, error) { + result := MessagesClientDequeueResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return MessagesClientDequeueResponse{}, err + } + result.Date = &date + } + if err := runtime.UnmarshalAsXML(resp, &result); err != nil { + return MessagesClientDequeueResponse{}, err + } + return result, nil +} + +// Enqueue - The Enqueue operation adds a new message to the back of the message queue. A visibility timeout can also be specified +// to make the message invisible until the visibility timeout expires. A message must +// be in a format that can be included in an XML request with UTF-8 encoding. The encoded message can be up to 64 KB in size +// for versions 2011-08-18 and newer, or 8 KB in size for previous versions. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// queueName - The queue name. +// queueMessage - A Message object which can be stored in a Queue +// options - MessagesClientEnqueueOptions contains the optional parameters for the MessagesClient.Enqueue method. +func (client *MessagesClient) Enqueue(ctx context.Context, queueName string, queueMessage QueueMessage, options *MessagesClientEnqueueOptions) (MessagesClientEnqueueResponse, error) { + req, err := client.enqueueCreateRequest(ctx, queueName, queueMessage, options) + if err != nil { + return MessagesClientEnqueueResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MessagesClientEnqueueResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusCreated) { + return MessagesClientEnqueueResponse{}, runtime.NewResponseError(resp) + } + return client.enqueueHandleResponse(resp) +} + +// enqueueCreateRequest creates the Enqueue request. +func (client *MessagesClient) enqueueCreateRequest(ctx context.Context, queueName string, queueMessage QueueMessage, options *MessagesClientEnqueueOptions) (*policy.Request, error) { + urlPath := "/{queueName}/messages" + if queueName == "" { + return nil, errors.New("parameter queueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Visibilitytimeout != nil { + reqQP.Set("visibilitytimeout", strconv.FormatInt(int64(*options.Visibilitytimeout), 10)) + } + if options != nil && options.MessageTimeToLive != nil { + reqQP.Set("messagettl", strconv.FormatInt(int64(*options.MessageTimeToLive), 10)) + } + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, runtime.MarshalAsXML(req, queueMessage) +} + +// enqueueHandleResponse handles the Enqueue response. +func (client *MessagesClient) enqueueHandleResponse(resp *http.Response) (MessagesClientEnqueueResponse, error) { + result := MessagesClientEnqueueResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return MessagesClientEnqueueResponse{}, err + } + result.Date = &date + } + if err := runtime.UnmarshalAsXML(resp, &result); err != nil { + return MessagesClientEnqueueResponse{}, err + } + return result, nil +} + +// Peek - The Peek operation retrieves one or more messages from the front of the queue, but does not alter the visibility +// of the message. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// queueName - The queue name. +// options - MessagesClientPeekOptions contains the optional parameters for the MessagesClient.Peek method. +func (client *MessagesClient) Peek(ctx context.Context, queueName string, options *MessagesClientPeekOptions) (MessagesClientPeekResponse, error) { + req, err := client.peekCreateRequest(ctx, queueName, options) + if err != nil { + return MessagesClientPeekResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return MessagesClientPeekResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MessagesClientPeekResponse{}, runtime.NewResponseError(resp) + } + return client.peekHandleResponse(resp) +} + +// peekCreateRequest creates the Peek request. +func (client *MessagesClient) peekCreateRequest(ctx context.Context, queueName string, options *MessagesClientPeekOptions) (*policy.Request, error) { + urlPath := "/{queueName}/messages" + if queueName == "" { + return nil, errors.New("parameter queueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("peekonly", "true") + if options != nil && options.NumberOfMessages != nil { + reqQP.Set("numofmessages", strconv.FormatInt(int64(*options.NumberOfMessages), 10)) + } + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// peekHandleResponse handles the Peek response. +func (client *MessagesClient) peekHandleResponse(resp *http.Response) (MessagesClientPeekResponse, error) { + result := MessagesClientPeekResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return MessagesClientPeekResponse{}, err + } + result.Date = &date + } + if err := runtime.UnmarshalAsXML(resp, &result); err != nil { + return MessagesClientPeekResponse{}, err + } + return result, nil +} + diff --git a/sdk/storage/azqueue/generated/zz_models.go b/sdk/storage/azqueue/generated/zz_models.go new file mode 100644 index 000000000000..eda90fa9c48e --- /dev/null +++ b/sdk/storage/azqueue/generated/zz_models.go @@ -0,0 +1,425 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package generated + +import "time" + +// AccessPolicy - An Access policy +type AccessPolicy struct { + // the date-time the policy expires + Expiry *time.Time `xml:"Expiry"` + + // the permissions for the acl policy + Permission *string `xml:"Permission"` + + // the date-time the policy is active + Start *time.Time `xml:"Start"` +} + +// CorsRule - CORS is an HTTP feature that enables a web application running under one domain to access resources in another +// domain. Web browsers implement a security restriction known as same-origin policy that +// prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin +// domain) to call APIs in another domain +type CorsRule struct { + // REQUIRED; the request headers that the origin domain may specify on the CORS request. + AllowedHeaders *string `xml:"AllowedHeaders"` + + // REQUIRED; The methods (HTTP request verbs) that the origin domain may use for a CORS request. (comma separated) + AllowedMethods *string `xml:"AllowedMethods"` + + // REQUIRED; The origin domains that are permitted to make a request against the storage service via CORS. The origin domain +// is the domain from which the request originates. Note that the origin must be an exact +// case-sensitive match with the origin that the user age sends to the service. You can also use the wildcard character '*' +// to allow all origin domains to make requests via CORS. + AllowedOrigins *string `xml:"AllowedOrigins"` + + // REQUIRED; The response headers that may be sent in the response to the CORS request and exposed by the browser to the request +// issuer + ExposedHeaders *string `xml:"ExposedHeaders"` + + // REQUIRED; The maximum amount time that a browser should cache the preflight OPTIONS request. + MaxAgeInSeconds *int32 `xml:"MaxAgeInSeconds"` +} + +// DequeuedMessageItem - The object returned in the QueueMessageList array when calling Get Messages on a Queue. +type DequeuedMessageItem struct { + // REQUIRED; The number of times the message has been dequeued. + DequeueCount *int64 `xml:"DequeueCount"` + + // REQUIRED; The time that the Message will expire and be automatically deleted. + ExpirationTime *time.Time `xml:"ExpirationTime"` + + // REQUIRED; The time the Message was inserted into the Queue. + InsertionTime *time.Time `xml:"InsertionTime"` + + // REQUIRED; The Id of the Message. + MessageID *string `xml:"MessageId"` + + // REQUIRED; The content of the Message. + MessageText *string `xml:"MessageText"` + + // REQUIRED; This value is required to delete the Message. If deletion fails using this popreceipt then the message has been +// dequeued by another client. + PopReceipt *string `xml:"PopReceipt"` + + // REQUIRED; The time that the message will again become visible in the Queue. + TimeNextVisible *time.Time `xml:"TimeNextVisible"` +} + +// EnqueuedMessage - The object returned in the QueueMessageList array when calling Put Message on a Queue +type EnqueuedMessage struct { + // REQUIRED; The time that the Message will expire and be automatically deleted. + ExpirationTime *time.Time `xml:"ExpirationTime"` + + // REQUIRED; The time the Message was inserted into the Queue. + InsertionTime *time.Time `xml:"InsertionTime"` + + // REQUIRED; The Id of the Message. + MessageID *string `xml:"MessageId"` + + // REQUIRED; This value is required to delete the Message. If deletion fails using this popreceipt then the message has been +// dequeued by another client. + PopReceipt *string `xml:"PopReceipt"` + + // REQUIRED; The time that the message will again become visible in the Queue. + TimeNextVisible *time.Time `xml:"TimeNextVisible"` +} + +type GeoReplication struct { + // REQUIRED; A GMT date/time value, to the second. All primary writes preceding this value are guaranteed to be available +// for read operations at the secondary. Primary writes after this point in time may or may +// not be available for reads. + LastSyncTime *time.Time `xml:"LastSyncTime"` + + // REQUIRED; The status of the secondary location + Status *GeoReplicationStatusType `xml:"Status"` +} + +// ListQueuesSegmentResponse - The object returned when calling List Queues on a Queue Service. +type ListQueuesSegmentResponse struct { + // REQUIRED + MaxResults *int32 `xml:"MaxResults"` + + // REQUIRED + NextMarker *string `xml:"NextMarker"` + + // REQUIRED + Prefix *string `xml:"Prefix"` + + // REQUIRED + ServiceEndpoint *string `xml:"ServiceEndpoint,attr"` + Marker *string `xml:"Marker"` + QueueItems []*QueueItem `xml:"Queues>Queue"` +} + +// Logging - Azure Analytics Logging settings. +type Logging struct { + // REQUIRED; Indicates whether all delete requests should be logged. + Delete *bool `xml:"Delete"` + + // REQUIRED; Indicates whether all read requests should be logged. + Read *bool `xml:"Read"` + + // REQUIRED; the retention policy + RetentionPolicy *RetentionPolicy `xml:"RetentionPolicy"` + + // REQUIRED; The version of Storage Analytics to configure. + Version *string `xml:"Version"` + + // REQUIRED; Indicates whether all write requests should be logged. + Write *bool `xml:"Write"` +} + +// MessageIDClientDeleteOptions contains the optional parameters for the MessageIDClient.Delete method. +type MessageIDClientDeleteOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// MessageIDClientUpdateOptions contains the optional parameters for the MessageIDClient.Update method. +type MessageIDClientUpdateOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// MessagesClientClearOptions contains the optional parameters for the MessagesClient.Clear method. +type MessagesClientClearOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// MessagesClientDequeueOptions contains the optional parameters for the MessagesClient.Dequeue method. +type MessagesClientDequeueOptions struct { + // Optional. A nonzero integer value that specifies the number of messages to retrieve from the queue, up to a maximum of +// 32. If fewer are visible, the visible messages are returned. By default, a single +// message is retrieved from the queue with this operation. + NumberOfMessages *int32 + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 + // Optional. Specifies the new visibility timeout value, in seconds, relative to server time. The default value is 30 seconds. +// A specified value must be larger than or equal to 1 second, and cannot be +// larger than 7 days, or larger than 2 hours on REST protocol versions prior to version 2011-08-18. The visibility timeout +// of a message can be set to a value later than the expiry time. + Visibilitytimeout *int32 +} + +// MessagesClientEnqueueOptions contains the optional parameters for the MessagesClient.Enqueue method. +type MessagesClientEnqueueOptions struct { + // Optional. Specifies the time-to-live interval for the message, in seconds. Prior to version 2017-07-29, the maximum time-to-live +// allowed is 7 days. For version 2017-07-29 or later, the maximum +// time-to-live can be any positive number, as well as -1 indicating that the message does not expire. If this parameter is +// omitted, the default time-to-live is 7 days. + MessageTimeToLive *int32 + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 + // Optional. If specified, the request must be made using an x-ms-version of 2011-08-18 or later. If not specified, the default +// value is 0. Specifies the new visibility timeout value, in seconds, +// relative to server time. The new value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility +// timeout of a message cannot be set to a value later than the expiry time. +// visibilitytimeout should be set to a value smaller than the time-to-live value. + Visibilitytimeout *int32 +} + +// MessagesClientPeekOptions contains the optional parameters for the MessagesClient.Peek method. +type MessagesClientPeekOptions struct { + // Optional. A nonzero integer value that specifies the number of messages to retrieve from the queue, up to a maximum of +// 32. If fewer are visible, the visible messages are returned. By default, a single +// message is retrieved from the queue with this operation. + NumberOfMessages *int32 + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// Metrics - a summary of request statistics grouped by API in hour or minute aggregates for queues +type Metrics struct { + // REQUIRED; Indicates whether metrics are enabled for the Queue service. + Enabled *bool `xml:"Enabled"` + + // Indicates whether metrics should generate summary statistics for called API operations. + IncludeAPIs *bool `xml:"IncludeAPIs"` + + // the retention policy + RetentionPolicy *RetentionPolicy `xml:"RetentionPolicy"` + + // The version of Storage Analytics to configure. + Version *string `xml:"Version"` +} + +// PeekedMessageItem - The object returned in the QueueMessageList array when calling Peek Messages on a Queue +type PeekedMessageItem struct { + // REQUIRED; The number of times the message has been dequeued. + DequeueCount *int64 `xml:"DequeueCount"` + + // REQUIRED; The time that the Message will expire and be automatically deleted. + ExpirationTime *time.Time `xml:"ExpirationTime"` + + // REQUIRED; The time the Message was inserted into the Queue. + InsertionTime *time.Time `xml:"InsertionTime"` + + // REQUIRED; The Id of the Message. + MessageID *string `xml:"MessageId"` + + // REQUIRED; The content of the Message. + MessageText *string `xml:"MessageText"` +} + +// QueueClientCreateOptions contains the optional parameters for the QueueClient.Create method. +type QueueClientCreateOptions struct { + // Optional. Include this parameter to specify that the queue's metadata be returned as part of the response body. Note that +// metadata requested with this parameter must be stored in accordance with the +// naming restrictions imposed by the 2009-09-19 version of the Queue service. Beginning with this version, all metadata names +// must adhere to the naming conventions for C# identifiers. + Metadata map[string]string + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// QueueClientDeleteOptions contains the optional parameters for the QueueClient.Delete method. +type QueueClientDeleteOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// QueueClientGetAccessPolicyOptions contains the optional parameters for the QueueClient.GetAccessPolicy method. +type QueueClientGetAccessPolicyOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// QueueClientGetPropertiesOptions contains the optional parameters for the QueueClient.GetProperties method. +type QueueClientGetPropertiesOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// QueueClientSetAccessPolicyOptions contains the optional parameters for the QueueClient.SetAccessPolicy method. +type QueueClientSetAccessPolicyOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// QueueClientSetMetadataOptions contains the optional parameters for the QueueClient.SetMetadata method. +type QueueClientSetMetadataOptions struct { + // Optional. Include this parameter to specify that the queue's metadata be returned as part of the response body. Note that +// metadata requested with this parameter must be stored in accordance with the +// naming restrictions imposed by the 2009-09-19 version of the Queue service. Beginning with this version, all metadata names +// must adhere to the naming conventions for C# identifiers. + Metadata map[string]string + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// QueueItem - An Azure Storage Queue. +type QueueItem struct { + // REQUIRED; The name of the Queue. + Name *string `xml:"Name"` + + // Dictionary of + Metadata map[string]*string `xml:"Metadata"` +} + +// QueueMessage - A Message object which can be stored in a Queue +type QueueMessage struct { + // REQUIRED; The content of the message + MessageText *string `xml:"MessageText"` +} + +// RetentionPolicy - the retention policy +type RetentionPolicy struct { + // REQUIRED; Indicates whether a retention policy is enabled for the storage service + Enabled *bool `xml:"Enabled"` + + // Indicates the number of days that metrics or logging or soft-deleted data should be retained. All data older than this +// value will be deleted + Days *int32 `xml:"Days"` +} + +// ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. +type ServiceClientGetPropertiesOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// ServiceClientGetStatisticsOptions contains the optional parameters for the ServiceClient.GetStatistics method. +type ServiceClientGetStatisticsOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// ServiceClientListQueuesSegmentOptions contains the optional parameters for the ServiceClient.ListQueuesSegment method. +type ServiceClientListQueuesSegmentOptions struct { + // Include this parameter to specify that the queues' metadata be returned as part of the response body. + Include []string + // A string value that identifies the portion of the list of queues to be returned with the next listing operation. The operation +// returns the NextMarker value within the response body if the listing +// operation did not return all queues remaining to be listed with the current page. The NextMarker value can be used as the +// value for the marker parameter in a subsequent call to request the next page +// of list items. The marker value is opaque to the client. + Marker *string + // Specifies the maximum number of queues to return. If the request does not specify maxresults, or specifies a value greater +// than 5000, the server will return up to 5000 items. Note that if the listing +// operation crosses a partition boundary, then the service will return a continuation token for retrieving the remainder +// of the results. For this reason, it is possible that the service will return +// fewer results than specified by maxresults, or than the default of 5000. + Maxresults *int32 + // Filters the results to return only queues whose name begins with the specified prefix. + Prefix *string + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. +type ServiceClientSetPropertiesOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage +// analytics logging is enabled. + RequestID *string + // The The timeout parameter is expressed in seconds. For more information, see + Timeout *int32 +} + +// SignedIdentifier - signed identifier +type SignedIdentifier struct { + // REQUIRED; The access policy + AccessPolicy *AccessPolicy `xml:"AccessPolicy"` + + // REQUIRED; a unique id + ID *string `xml:"Id"` +} + +type StorageError struct { + Message *string `json:"Message,omitempty"` +} + +// StorageServiceProperties - Storage Service Properties. +type StorageServiceProperties struct { + // The set of CORS rules. + Cors []*CorsRule `xml:"Cors>CorsRule"` + + // A summary of request statistics grouped by API in hourly aggregates for queues + HourMetrics *Metrics `xml:"HourMetrics"` + + // Azure Analytics Logging settings + Logging *Logging `xml:"Logging"` + + // a summary of request statistics grouped by API in minute aggregates for queues + MinuteMetrics *Metrics `xml:"MinuteMetrics"` +} + +// StorageServiceStats - Stats for the storage service. +type StorageServiceStats struct { + // Geo-Replication information for the Secondary Storage Service + GeoReplication *GeoReplication `xml:"GeoReplication"` +} + diff --git a/sdk/storage/azqueue/generated/zz_models_serde.go b/sdk/storage/azqueue/generated/zz_models_serde.go new file mode 100644 index 000000000000..e34236f6e5b3 --- /dev/null +++ b/sdk/storage/azqueue/generated/zz_models_serde.go @@ -0,0 +1,282 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package generated + +import ( + "encoding/json" + "encoding/xml" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// MarshalXML implements the xml.Marshaller interface for type AccessPolicy. +func (a AccessPolicy) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + type alias AccessPolicy + aux := &struct { + *alias + Expiry *timeRFC3339 `xml:"Expiry"` + Start *timeRFC3339 `xml:"Start"` + }{ + alias: (*alias)(&a), + Expiry: (*timeRFC3339)(a.Expiry), + Start: (*timeRFC3339)(a.Start), + } + return e.EncodeElement(aux, start) +} + +// UnmarshalXML implements the xml.Unmarshaller interface for type AccessPolicy. +func (a *AccessPolicy) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + type alias AccessPolicy + aux := &struct { + *alias + Expiry *timeRFC3339 `xml:"Expiry"` + Start *timeRFC3339 `xml:"Start"` + }{ + alias: (*alias)(a), + } + if err := d.DecodeElement(aux, &start); err != nil { + return err + } + a.Expiry = (*time.Time)(aux.Expiry) + a.Start = (*time.Time)(aux.Start) + return nil +} + +// MarshalXML implements the xml.Marshaller interface for type DequeuedMessageItem. +func (d DequeuedMessageItem) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + type alias DequeuedMessageItem + aux := &struct { + *alias + ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` + InsertionTime *timeRFC1123 `xml:"InsertionTime"` + TimeNextVisible *timeRFC1123 `xml:"TimeNextVisible"` + }{ + alias: (*alias)(&d), + ExpirationTime: (*timeRFC1123)(d.ExpirationTime), + InsertionTime: (*timeRFC1123)(d.InsertionTime), + TimeNextVisible: (*timeRFC1123)(d.TimeNextVisible), + } + return e.EncodeElement(aux, start) +} + +// UnmarshalXML implements the xml.Unmarshaller interface for type DequeuedMessageItem. +func (d *DequeuedMessageItem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + type alias DequeuedMessageItem + aux := &struct { + *alias + ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` + InsertionTime *timeRFC1123 `xml:"InsertionTime"` + TimeNextVisible *timeRFC1123 `xml:"TimeNextVisible"` + }{ + alias: (*alias)(d), + } + if err := d.DecodeElement(aux, &start); err != nil { + return err + } + d.ExpirationTime = (*time.Time)(aux.ExpirationTime) + d.InsertionTime = (*time.Time)(aux.InsertionTime) + d.TimeNextVisible = (*time.Time)(aux.TimeNextVisible) + return nil +} + +// MarshalXML implements the xml.Marshaller interface for type EnqueuedMessage. +func (e EnqueuedMessage) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + type alias EnqueuedMessage + aux := &struct { + *alias + ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` + InsertionTime *timeRFC1123 `xml:"InsertionTime"` + TimeNextVisible *timeRFC1123 `xml:"TimeNextVisible"` + }{ + alias: (*alias)(&e), + ExpirationTime: (*timeRFC1123)(e.ExpirationTime), + InsertionTime: (*timeRFC1123)(e.InsertionTime), + TimeNextVisible: (*timeRFC1123)(e.TimeNextVisible), + } + return e.EncodeElement(aux, start) +} + +// UnmarshalXML implements the xml.Unmarshaller interface for type EnqueuedMessage. +func (e *EnqueuedMessage) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + type alias EnqueuedMessage + aux := &struct { + *alias + ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` + InsertionTime *timeRFC1123 `xml:"InsertionTime"` + TimeNextVisible *timeRFC1123 `xml:"TimeNextVisible"` + }{ + alias: (*alias)(e), + } + if err := d.DecodeElement(aux, &start); err != nil { + return err + } + e.ExpirationTime = (*time.Time)(aux.ExpirationTime) + e.InsertionTime = (*time.Time)(aux.InsertionTime) + e.TimeNextVisible = (*time.Time)(aux.TimeNextVisible) + return nil +} + +// MarshalXML implements the xml.Marshaller interface for type GeoReplication. +func (g GeoReplication) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + type alias GeoReplication + aux := &struct { + *alias + LastSyncTime *timeRFC1123 `xml:"LastSyncTime"` + }{ + alias: (*alias)(&g), + LastSyncTime: (*timeRFC1123)(g.LastSyncTime), + } + return e.EncodeElement(aux, start) +} + +// UnmarshalXML implements the xml.Unmarshaller interface for type GeoReplication. +func (g *GeoReplication) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + type alias GeoReplication + aux := &struct { + *alias + LastSyncTime *timeRFC1123 `xml:"LastSyncTime"` + }{ + alias: (*alias)(g), + } + if err := d.DecodeElement(aux, &start); err != nil { + return err + } + g.LastSyncTime = (*time.Time)(aux.LastSyncTime) + return nil +} + +// MarshalXML implements the xml.Marshaller interface for type ListQueuesSegmentResponse. +func (l ListQueuesSegmentResponse) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + type alias ListQueuesSegmentResponse + aux := &struct { + *alias + QueueItems *[]*QueueItem `xml:"Queues>Queue"` + }{ + alias: (*alias)(&l), + } + if l.QueueItems != nil { + aux.QueueItems = &l.QueueItems + } + return e.EncodeElement(aux, start) +} + +// MarshalXML implements the xml.Marshaller interface for type PeekedMessageItem. +func (p PeekedMessageItem) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + type alias PeekedMessageItem + aux := &struct { + *alias + ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` + InsertionTime *timeRFC1123 `xml:"InsertionTime"` + }{ + alias: (*alias)(&p), + ExpirationTime: (*timeRFC1123)(p.ExpirationTime), + InsertionTime: (*timeRFC1123)(p.InsertionTime), + } + return e.EncodeElement(aux, start) +} + +// UnmarshalXML implements the xml.Unmarshaller interface for type PeekedMessageItem. +func (p *PeekedMessageItem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + type alias PeekedMessageItem + aux := &struct { + *alias + ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` + InsertionTime *timeRFC1123 `xml:"InsertionTime"` + }{ + alias: (*alias)(p), + } + if err := d.DecodeElement(aux, &start); err != nil { + return err + } + p.ExpirationTime = (*time.Time)(aux.ExpirationTime) + p.InsertionTime = (*time.Time)(aux.InsertionTime) + return nil +} + +// UnmarshalXML implements the xml.Unmarshaller interface for type QueueItem. +func (q *QueueItem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + type alias QueueItem + aux := &struct { + *alias + Metadata additionalProperties `xml:"Metadata"` + }{ + alias: (*alias)(q), + } + if err := d.DecodeElement(aux, &start); err != nil { + return err + } + q.Metadata = (map[string]*string)(aux.Metadata) + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageError. +func (s StorageError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "Message", s.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageError. +func (s *StorageError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "Message": + err = unpopulate(val, "Message", &s.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalXML implements the xml.Marshaller interface for type StorageServiceProperties. +func (s StorageServiceProperties) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + type alias StorageServiceProperties + aux := &struct { + *alias + Cors *[]*CorsRule `xml:"Cors>CorsRule"` + }{ + alias: (*alias)(&s), + } + if s.Cors != nil { + aux.Cors = &s.Cors + } + return e.EncodeElement(aux, start) +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v interface{}) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} + diff --git a/sdk/storage/azqueue/generated/zz_queue_client.go b/sdk/storage/azqueue/generated/zz_queue_client.go new file mode 100644 index 000000000000..d8b34d1b881d --- /dev/null +++ b/sdk/storage/azqueue/generated/zz_queue_client.go @@ -0,0 +1,460 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package generated + +import ( + "context" + "encoding/xml" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// QueueClient contains the methods for the Queue group. +// Don't use this type directly, use NewQueueClient() instead. +type QueueClient struct { + endpoint string + pl runtime.Pipeline +} + +// NewQueueClient creates a new instance of QueueClient with the specified values. +// endpoint - The URL of the service account, queue or message that is the target of the desired operation. +// pl - the pipeline used for sending requests and handling responses. +func NewQueueClient(endpoint string, pl runtime.Pipeline) *QueueClient { + client := &QueueClient{ + endpoint: endpoint, + pl: pl, + } + return client +} + +// Create - creates a new queue under the given account. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// queueName - The queue name. +// options - QueueClientCreateOptions contains the optional parameters for the QueueClient.Create method. +func (client *QueueClient) Create(ctx context.Context, queueName string, options *QueueClientCreateOptions) (QueueClientCreateResponse, error) { + req, err := client.createCreateRequest(ctx, queueName, options) + if err != nil { + return QueueClientCreateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return QueueClientCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusCreated, http.StatusNoContent) { + return QueueClientCreateResponse{}, runtime.NewResponseError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *QueueClient) createCreateRequest(ctx context.Context, queueName string, options *QueueClientCreateOptions) (*policy.Request, error) { + urlPath := "/{queueName}" + if queueName == "" { + return nil, errors.New("parameter queueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.Metadata != nil { + for k, v := range options.Metadata { + req.Raw().Header["x-ms-meta-"+k] = []string{v} + } + } + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// createHandleResponse handles the Create response. +func (client *QueueClient) createHandleResponse(resp *http.Response) (QueueClientCreateResponse, error) { + result := QueueClientCreateResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return QueueClientCreateResponse{}, err + } + result.Date = &date + } + return result, nil +} + +// Delete - operation permanently deletes the specified queue +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// queueName - The queue name. +// options - QueueClientDeleteOptions contains the optional parameters for the QueueClient.Delete method. +func (client *QueueClient) Delete(ctx context.Context, queueName string, options *QueueClientDeleteOptions) (QueueClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, queueName, options) + if err != nil { + return QueueClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return QueueClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusNoContent) { + return QueueClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return client.deleteHandleResponse(resp) +} + +// deleteCreateRequest creates the Delete request. +func (client *QueueClient) deleteCreateRequest(ctx context.Context, queueName string, options *QueueClientDeleteOptions) (*policy.Request, error) { + urlPath := "/{queueName}" + if queueName == "" { + return nil, errors.New("parameter queueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// deleteHandleResponse handles the Delete response. +func (client *QueueClient) deleteHandleResponse(resp *http.Response) (QueueClientDeleteResponse, error) { + result := QueueClientDeleteResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return QueueClientDeleteResponse{}, err + } + result.Date = &date + } + return result, nil +} + +// GetAccessPolicy - returns details about any stored access policies specified on the queue that may be used with Shared +// Access Signatures. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// queueName - The queue name. +// options - QueueClientGetAccessPolicyOptions contains the optional parameters for the QueueClient.GetAccessPolicy method. +func (client *QueueClient) GetAccessPolicy(ctx context.Context, queueName string, options *QueueClientGetAccessPolicyOptions) (QueueClientGetAccessPolicyResponse, error) { + req, err := client.getAccessPolicyCreateRequest(ctx, queueName, options) + if err != nil { + return QueueClientGetAccessPolicyResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return QueueClientGetAccessPolicyResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return QueueClientGetAccessPolicyResponse{}, runtime.NewResponseError(resp) + } + return client.getAccessPolicyHandleResponse(resp) +} + +// getAccessPolicyCreateRequest creates the GetAccessPolicy request. +func (client *QueueClient) getAccessPolicyCreateRequest(ctx context.Context, queueName string, options *QueueClientGetAccessPolicyOptions) (*policy.Request, error) { + urlPath := "/{queueName}" + if queueName == "" { + return nil, errors.New("parameter queueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("comp", "acl") + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// getAccessPolicyHandleResponse handles the GetAccessPolicy response. +func (client *QueueClient) getAccessPolicyHandleResponse(resp *http.Response) (QueueClientGetAccessPolicyResponse, error) { + result := QueueClientGetAccessPolicyResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return QueueClientGetAccessPolicyResponse{}, err + } + result.Date = &date + } + if err := runtime.UnmarshalAsXML(resp, &result); err != nil { + return QueueClientGetAccessPolicyResponse{}, err + } + return result, nil +} + +// GetProperties - Retrieves user-defined metadata and queue properties on the specified queue. Metadata is associated with +// the queue as name-values pairs. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// queueName - The queue name. +// options - QueueClientGetPropertiesOptions contains the optional parameters for the QueueClient.GetProperties method. +func (client *QueueClient) GetProperties(ctx context.Context, queueName string, options *QueueClientGetPropertiesOptions) (QueueClientGetPropertiesResponse, error) { + req, err := client.getPropertiesCreateRequest(ctx, queueName, options) + if err != nil { + return QueueClientGetPropertiesResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return QueueClientGetPropertiesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return QueueClientGetPropertiesResponse{}, runtime.NewResponseError(resp) + } + return client.getPropertiesHandleResponse(resp) +} + +// getPropertiesCreateRequest creates the GetProperties request. +func (client *QueueClient) getPropertiesCreateRequest(ctx context.Context, queueName string, options *QueueClientGetPropertiesOptions) (*policy.Request, error) { + urlPath := "/{queueName}" + if queueName == "" { + return nil, errors.New("parameter queueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("comp", "metadata") + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// getPropertiesHandleResponse handles the GetProperties response. +func (client *QueueClient) getPropertiesHandleResponse(resp *http.Response) (QueueClientGetPropertiesResponse, error) { + result := QueueClientGetPropertiesResponse{} + for hh := range resp.Header { + if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { + if result.Metadata == nil { + result.Metadata = map[string]string{} + } + result.Metadata[hh[len("x-ms-meta-"):]] = resp.Header.Get(hh) + } + } + if val := resp.Header.Get("x-ms-approximate-messages-count"); val != "" { + approximateMessagesCount32, err := strconv.ParseInt(val, 10, 32) + approximateMessagesCount := int32(approximateMessagesCount32) + if err != nil { + return QueueClientGetPropertiesResponse{}, err + } + result.ApproximateMessagesCount = &approximateMessagesCount + } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return QueueClientGetPropertiesResponse{}, err + } + result.Date = &date + } + return result, nil +} + +// SetAccessPolicy - sets stored access policies for the queue that may be used with Shared Access Signatures +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// queueName - The queue name. +// queueACL - the acls for the queue +// options - QueueClientSetAccessPolicyOptions contains the optional parameters for the QueueClient.SetAccessPolicy method. +func (client *QueueClient) SetAccessPolicy(ctx context.Context, queueName string, queueACL []*SignedIdentifier, options *QueueClientSetAccessPolicyOptions) (QueueClientSetAccessPolicyResponse, error) { + req, err := client.setAccessPolicyCreateRequest(ctx, queueName, queueACL, options) + if err != nil { + return QueueClientSetAccessPolicyResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return QueueClientSetAccessPolicyResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusNoContent) { + return QueueClientSetAccessPolicyResponse{}, runtime.NewResponseError(resp) + } + return client.setAccessPolicyHandleResponse(resp) +} + +// setAccessPolicyCreateRequest creates the SetAccessPolicy request. +func (client *QueueClient) setAccessPolicyCreateRequest(ctx context.Context, queueName string, queueACL []*SignedIdentifier, options *QueueClientSetAccessPolicyOptions) (*policy.Request, error) { + urlPath := "/{queueName}" + if queueName == "" { + return nil, errors.New("parameter queueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("comp", "acl") + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + type wrapper struct { + XMLName xml.Name `xml:"SignedIdentifiers"` + QueueACL *[]*SignedIdentifier `xml:"SignedIdentifier"` + } + return req, runtime.MarshalAsXML(req, wrapper{QueueACL: &queueACL}) +} + +// setAccessPolicyHandleResponse handles the SetAccessPolicy response. +func (client *QueueClient) setAccessPolicyHandleResponse(resp *http.Response) (QueueClientSetAccessPolicyResponse, error) { + result := QueueClientSetAccessPolicyResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return QueueClientSetAccessPolicyResponse{}, err + } + result.Date = &date + } + return result, nil +} + +// SetMetadata - sets user-defined metadata on the specified queue. Metadata is associated with the queue as name-value pairs. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// queueName - The queue name. +// options - QueueClientSetMetadataOptions contains the optional parameters for the QueueClient.SetMetadata method. +func (client *QueueClient) SetMetadata(ctx context.Context, queueName string, options *QueueClientSetMetadataOptions) (QueueClientSetMetadataResponse, error) { + req, err := client.setMetadataCreateRequest(ctx, queueName, options) + if err != nil { + return QueueClientSetMetadataResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return QueueClientSetMetadataResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusNoContent) { + return QueueClientSetMetadataResponse{}, runtime.NewResponseError(resp) + } + return client.setMetadataHandleResponse(resp) +} + +// setMetadataCreateRequest creates the SetMetadata request. +func (client *QueueClient) setMetadataCreateRequest(ctx context.Context, queueName string, options *QueueClientSetMetadataOptions) (*policy.Request, error) { + urlPath := "/{queueName}" + if queueName == "" { + return nil, errors.New("parameter queueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.endpoint, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("comp", "metadata") + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + if options != nil && options.Metadata != nil { + for k, v := range options.Metadata { + req.Raw().Header["x-ms-meta-"+k] = []string{v} + } + } + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// setMetadataHandleResponse handles the SetMetadata response. +func (client *QueueClient) setMetadataHandleResponse(resp *http.Response) (QueueClientSetMetadataResponse, error) { + result := QueueClientSetMetadataResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return QueueClientSetMetadataResponse{}, err + } + result.Date = &date + } + return result, nil +} + diff --git a/sdk/storage/azqueue/generated/zz_response_types.go b/sdk/storage/azqueue/generated/zz_response_types.go new file mode 100644 index 000000000000..128459f4704c --- /dev/null +++ b/sdk/storage/azqueue/generated/zz_response_types.go @@ -0,0 +1,226 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package generated + +import "time" + +// MessageIDClientDeleteResponse contains the response from method MessageIDClient.Delete. +type MessageIDClientDeleteResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string + + // Version contains the information returned from the x-ms-version header response. + Version *string +} + +// MessageIDClientUpdateResponse contains the response from method MessageIDClient.Update. +type MessageIDClientUpdateResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time + + // PopReceipt contains the information returned from the x-ms-popreceipt header response. + PopReceipt *string + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string + + // TimeNextVisible contains the information returned from the x-ms-time-next-visible header response. + TimeNextVisible *time.Time + + // Version contains the information returned from the x-ms-version header response. + Version *string +} + +// MessagesClientClearResponse contains the response from method MessagesClient.Clear. +type MessagesClientClearResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string + + // Version contains the information returned from the x-ms-version header response. + Version *string +} + +// MessagesClientDequeueResponse contains the response from method MessagesClient.Dequeue. +type MessagesClientDequeueResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time `xml:"Date"` + + // The object returned when calling Get Messages on a Queue + QueueMessagesList []*DequeuedMessageItem `xml:"QueueMessage"` + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string `xml:"RequestID"` + + // Version contains the information returned from the x-ms-version header response. + Version *string `xml:"Version"` +} + +// MessagesClientEnqueueResponse contains the response from method MessagesClient.Enqueue. +type MessagesClientEnqueueResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time `xml:"Date"` + + // The object returned when calling Put Message on a Queue + QueueMessagesList []*EnqueuedMessage `xml:"QueueMessage"` + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string `xml:"RequestID"` + + // Version contains the information returned from the x-ms-version header response. + Version *string `xml:"Version"` +} + +// MessagesClientPeekResponse contains the response from method MessagesClient.Peek. +type MessagesClientPeekResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time `xml:"Date"` + + // The object returned when calling Peek Messages on a Queue + QueueMessagesList []*PeekedMessageItem `xml:"QueueMessage"` + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string `xml:"RequestID"` + + // Version contains the information returned from the x-ms-version header response. + Version *string `xml:"Version"` +} + +// QueueClientCreateResponse contains the response from method QueueClient.Create. +type QueueClientCreateResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string + + // Version contains the information returned from the x-ms-version header response. + Version *string +} + +// QueueClientDeleteResponse contains the response from method QueueClient.Delete. +type QueueClientDeleteResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string + + // Version contains the information returned from the x-ms-version header response. + Version *string +} + +// QueueClientGetAccessPolicyResponse contains the response from method QueueClient.GetAccessPolicy. +type QueueClientGetAccessPolicyResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time `xml:"Date"` + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string `xml:"RequestID"` + + // a collection of signed identifiers + SignedIdentifiers []*SignedIdentifier `xml:"SignedIdentifier"` + + // Version contains the information returned from the x-ms-version header response. + Version *string `xml:"Version"` +} + +// QueueClientGetPropertiesResponse contains the response from method QueueClient.GetProperties. +type QueueClientGetPropertiesResponse struct { + // ApproximateMessagesCount contains the information returned from the x-ms-approximate-messages-count header response. + ApproximateMessagesCount *int32 + + // Date contains the information returned from the Date header response. + Date *time.Time + + // Metadata contains the information returned from the x-ms-meta header response. + Metadata map[string]string + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string + + // Version contains the information returned from the x-ms-version header response. + Version *string +} + +// QueueClientSetAccessPolicyResponse contains the response from method QueueClient.SetAccessPolicy. +type QueueClientSetAccessPolicyResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string + + // Version contains the information returned from the x-ms-version header response. + Version *string +} + +// QueueClientSetMetadataResponse contains the response from method QueueClient.SetMetadata. +type QueueClientSetMetadataResponse struct { + // Date contains the information returned from the Date header response. + Date *time.Time + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string + + // Version contains the information returned from the x-ms-version header response. + Version *string +} + +// ServiceClientGetPropertiesResponse contains the response from method ServiceClient.GetProperties. +type ServiceClientGetPropertiesResponse struct { + StorageServiceProperties + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string `xml:"RequestID"` + + // Version contains the information returned from the x-ms-version header response. + Version *string `xml:"Version"` +} + +// ServiceClientGetStatisticsResponse contains the response from method ServiceClient.GetStatistics. +type ServiceClientGetStatisticsResponse struct { + StorageServiceStats + // Date contains the information returned from the Date header response. + Date *time.Time `xml:"Date"` + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string `xml:"RequestID"` + + // Version contains the information returned from the x-ms-version header response. + Version *string `xml:"Version"` +} + +// ServiceClientListQueuesSegmentResponse contains the response from method ServiceClient.ListQueuesSegment. +type ServiceClientListQueuesSegmentResponse struct { + ListQueuesSegmentResponse + // Date contains the information returned from the Date header response. + Date *time.Time `xml:"Date"` + + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string `xml:"RequestID"` + + // Version contains the information returned from the x-ms-version header response. + Version *string `xml:"Version"` +} + +// ServiceClientSetPropertiesResponse contains the response from method ServiceClient.SetProperties. +type ServiceClientSetPropertiesResponse struct { + // RequestID contains the information returned from the x-ms-request-id header response. + RequestID *string + + // Version contains the information returned from the x-ms-version header response. + Version *string +} + diff --git a/sdk/storage/azqueue/generated/zz_service_client.go b/sdk/storage/azqueue/generated/zz_service_client.go new file mode 100644 index 000000000000..c426f66bd783 --- /dev/null +++ b/sdk/storage/azqueue/generated/zz_service_client.go @@ -0,0 +1,301 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package generated + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strconv" + "strings" + "time" +) + +// ServiceClient contains the methods for the Service group. +// Don't use this type directly, use NewServiceClient() instead. +type ServiceClient struct { + endpoint string + pl runtime.Pipeline +} + +// NewServiceClient creates a new instance of ServiceClient with the specified values. +// endpoint - The URL of the service account, queue or message that is the target of the desired operation. +// pl - the pipeline used for sending requests and handling responses. +func NewServiceClient(endpoint string, pl runtime.Pipeline) *ServiceClient { + client := &ServiceClient{ + endpoint: endpoint, + pl: pl, + } + return client +} + +// GetProperties - gets the properties of a storage account's Queue service, including properties for Storage Analytics and +// CORS (Cross-Origin Resource Sharing) rules. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// options - ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. +func (client *ServiceClient) GetProperties(ctx context.Context, options *ServiceClientGetPropertiesOptions) (ServiceClientGetPropertiesResponse, error) { + req, err := client.getPropertiesCreateRequest(ctx, options) + if err != nil { + return ServiceClientGetPropertiesResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ServiceClientGetPropertiesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ServiceClientGetPropertiesResponse{}, runtime.NewResponseError(resp) + } + return client.getPropertiesHandleResponse(resp) +} + +// getPropertiesCreateRequest creates the GetProperties request. +func (client *ServiceClient) getPropertiesCreateRequest(ctx context.Context, options *ServiceClientGetPropertiesOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodGet, client.endpoint) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("restype", "service") + reqQP.Set("comp", "properties") + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// getPropertiesHandleResponse handles the GetProperties response. +func (client *ServiceClient) getPropertiesHandleResponse(resp *http.Response) (ServiceClientGetPropertiesResponse, error) { + result := ServiceClientGetPropertiesResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if err := runtime.UnmarshalAsXML(resp, &result.StorageServiceProperties); err != nil { + return ServiceClientGetPropertiesResponse{}, err + } + return result, nil +} + +// GetStatistics - Retrieves statistics related to replication for the Queue service. It is only available on the secondary +// location endpoint when read-access geo-redundant replication is enabled for the storage +// account. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// options - ServiceClientGetStatisticsOptions contains the optional parameters for the ServiceClient.GetStatistics method. +func (client *ServiceClient) GetStatistics(ctx context.Context, options *ServiceClientGetStatisticsOptions) (ServiceClientGetStatisticsResponse, error) { + req, err := client.getStatisticsCreateRequest(ctx, options) + if err != nil { + return ServiceClientGetStatisticsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ServiceClientGetStatisticsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ServiceClientGetStatisticsResponse{}, runtime.NewResponseError(resp) + } + return client.getStatisticsHandleResponse(resp) +} + +// getStatisticsCreateRequest creates the GetStatistics request. +func (client *ServiceClient) getStatisticsCreateRequest(ctx context.Context, options *ServiceClientGetStatisticsOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodGet, client.endpoint) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("restype", "service") + reqQP.Set("comp", "stats") + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// getStatisticsHandleResponse handles the GetStatistics response. +func (client *ServiceClient) getStatisticsHandleResponse(resp *http.Response) (ServiceClientGetStatisticsResponse, error) { + result := ServiceClientGetStatisticsResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ServiceClientGetStatisticsResponse{}, err + } + result.Date = &date + } + if err := runtime.UnmarshalAsXML(resp, &result.StorageServiceStats); err != nil { + return ServiceClientGetStatisticsResponse{}, err + } + return result, nil +} + +// NewListQueuesSegmentPager - The List Queues Segment operation returns a list of the queues under the specified account +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// options - ServiceClientListQueuesSegmentOptions contains the optional parameters for the ServiceClient.ListQueuesSegment +// method. +func (client *ServiceClient) NewListQueuesSegmentPager(options *ServiceClientListQueuesSegmentOptions) (*runtime.Pager[ServiceClientListQueuesSegmentResponse]) { + return runtime.NewPager(runtime.PagingHandler[ServiceClientListQueuesSegmentResponse]{ + More: func(page ServiceClientListQueuesSegmentResponse) bool { + return page.NextMarker != nil && len(*page.NextMarker) > 0 + }, + Fetcher: func(ctx context.Context, page *ServiceClientListQueuesSegmentResponse) (ServiceClientListQueuesSegmentResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listQueuesSegmentCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextMarker) + } + if err != nil { + return ServiceClientListQueuesSegmentResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ServiceClientListQueuesSegmentResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ServiceClientListQueuesSegmentResponse{}, runtime.NewResponseError(resp) + } + return client.listQueuesSegmentHandleResponse(resp) + }, + }) +} + +// listQueuesSegmentCreateRequest creates the ListQueuesSegment request. +func (client *ServiceClient) listQueuesSegmentCreateRequest(ctx context.Context, options *ServiceClientListQueuesSegmentOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodGet, client.endpoint) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("comp", "list") + if options != nil && options.Prefix != nil { + reqQP.Set("prefix", *options.Prefix) + } + if options != nil && options.Marker != nil { + reqQP.Set("marker", *options.Marker) + } + if options != nil && options.Maxresults != nil { + reqQP.Set("maxresults", strconv.FormatInt(int64(*options.Maxresults), 10)) + } + if options != nil && options.Include != nil { + reqQP.Set("include", strings.Join(strings.Fields(strings.Trim(fmt.Sprint(options.Include), "[]")), ",")) + } + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, nil +} + +// listQueuesSegmentHandleResponse handles the ListQueuesSegment response. +func (client *ServiceClient) listQueuesSegmentHandleResponse(resp *http.Response) (ServiceClientListQueuesSegmentResponse, error) { + result := ServiceClientListQueuesSegmentResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ServiceClientListQueuesSegmentResponse{}, err + } + result.Date = &date + } + if err := runtime.UnmarshalAsXML(resp, &result.ListQueuesSegmentResponse); err != nil { + return ServiceClientListQueuesSegmentResponse{}, err + } + return result, nil +} + +// SetProperties - Sets properties for a storage account's Queue service endpoint, including properties for Storage Analytics +// and CORS (Cross-Origin Resource Sharing) rules +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2018-03-28 +// storageServiceProperties - The StorageService properties. +// options - ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. +func (client *ServiceClient) SetProperties(ctx context.Context, storageServiceProperties StorageServiceProperties, options *ServiceClientSetPropertiesOptions) (ServiceClientSetPropertiesResponse, error) { + req, err := client.setPropertiesCreateRequest(ctx, storageServiceProperties, options) + if err != nil { + return ServiceClientSetPropertiesResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ServiceClientSetPropertiesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted) { + return ServiceClientSetPropertiesResponse{}, runtime.NewResponseError(resp) + } + return client.setPropertiesHandleResponse(resp) +} + +// setPropertiesCreateRequest creates the SetProperties request. +func (client *ServiceClient) setPropertiesCreateRequest(ctx context.Context, storageServiceProperties StorageServiceProperties, options *ServiceClientSetPropertiesOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("restype", "service") + reqQP.Set("comp", "properties") + if options != nil && options.Timeout != nil { + reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["x-ms-version"] = []string{"2018-03-28"} + if options != nil && options.RequestID != nil { + req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} + } + req.Raw().Header["Accept"] = []string{"application/xml"} + return req, runtime.MarshalAsXML(req, storageServiceProperties) +} + +// setPropertiesHandleResponse handles the SetProperties response. +func (client *ServiceClient) setPropertiesHandleResponse(resp *http.Response) (ServiceClientSetPropertiesResponse, error) { + result := ServiceClientSetPropertiesResponse{} + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + return result, nil +} + diff --git a/sdk/storage/azqueue/generated/zz_time_rfc1123.go b/sdk/storage/azqueue/generated/zz_time_rfc1123.go new file mode 100644 index 000000000000..6fb227e0d505 --- /dev/null +++ b/sdk/storage/azqueue/generated/zz_time_rfc1123.go @@ -0,0 +1,47 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package generated + + + +import ( + "strings" + "time" +) + + + +const ( + rfc1123JSON = `"` + time.RFC1123 + `"` +) + +type timeRFC1123 time.Time + +func (t timeRFC1123) MarshalJSON() ([]byte, error) { + b := []byte(time.Time(t).Format(rfc1123JSON)) + return b, nil +} + +func (t timeRFC1123) MarshalText() ([]byte, error) { + b := []byte(time.Time(t).Format(time.RFC1123)) + return b, nil +} + +func (t *timeRFC1123) UnmarshalJSON(data []byte) error { + p, err := time.Parse(rfc1123JSON, strings.ToUpper(string(data))) + *t = timeRFC1123(p) + return err +} + +func (t *timeRFC1123) UnmarshalText(data []byte) error { + p, err := time.Parse(time.RFC1123, string(data)) + *t = timeRFC1123(p) + return err +} diff --git a/sdk/storage/azqueue/generated/zz_time_rfc3339.go b/sdk/storage/azqueue/generated/zz_time_rfc3339.go new file mode 100644 index 000000000000..e19af161526c --- /dev/null +++ b/sdk/storage/azqueue/generated/zz_time_rfc3339.go @@ -0,0 +1,63 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package generated + + + +import ( + "regexp" + "strings" + "time" +) + + + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} diff --git a/sdk/storage/azqueue/generated/zz_xml_helper.go b/sdk/storage/azqueue/generated/zz_xml_helper.go new file mode 100644 index 000000000000..c517807bd03a --- /dev/null +++ b/sdk/storage/azqueue/generated/zz_xml_helper.go @@ -0,0 +1,42 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package generated + +import ( + "encoding/xml" + "strings" +) + + +type additionalProperties map[string]*string + +// UnmarshalXML implements the xml.Unmarshaler interface for additionalProperties. +func (ap *additionalProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + tokName := "" + for t, err := d.Token(); err == nil; t, err = d.Token() { + switch tt := t.(type) { + case xml.StartElement: + tokName = strings.ToLower(tt.Name.Local) + break + case xml.CharData: + if tokName == "" { + continue + } + if *ap == nil { + *ap = additionalProperties{} + } + s := string(tt) + (*ap)[tokName] = &s + tokName = "" + break + } + } + return nil +} diff --git a/sdk/storage/azqueue/internal/autorest.md b/sdk/storage/azqueue/internal/autorest.md new file mode 100644 index 000000000000..1052245bcbfa --- /dev/null +++ b/sdk/storage/azqueue/internal/autorest.md @@ -0,0 +1,23 @@ +# Code Generation - Azure Blob SDK for Golang + +### Settings + +```yaml +go: true +clear-output-folder: false +version: "^3.0.0" +license-header: MICROSOFT_MIT_NO_VERSION +input-file: "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/storage/data-plane/Microsoft.QueueStorage/preview/2018-03-28/queue.json" +credential-scope: "https://storage.azure.com/.default" +output-folder: ../generated +file-prefix: "zz_" +openapi-type: "data-plane" +verbose: true +security: AzureKey +modelerfour: + group-parameters: false + seal-single-value-enum-by-default: true + lenient-model-deduplication: true +export-clients: true +use: "@autorest/go@4.0.0-preview.43" +``` From 112696684b7b9f6c6a95e84717af1f7f75c6b19f Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Tue, 27 Dec 2022 14:12:22 -0800 Subject: [PATCH 02/17] removed queuename from url param --- .../azqueue/generated/zz_messageid_client.go | 41 ++------- .../azqueue/generated/zz_messages_client.go | 59 ++++--------- .../azqueue/generated/zz_queue_client.go | 86 ++++++------------- sdk/storage/azqueue/go.mod | 11 +++ sdk/storage/azqueue/go.sum | 12 +++ sdk/storage/azqueue/internal/autorest.md | 29 +++++++ 6 files changed, 100 insertions(+), 138 deletions(-) create mode 100644 sdk/storage/azqueue/go.mod create mode 100644 sdk/storage/azqueue/go.sum diff --git a/sdk/storage/azqueue/generated/zz_messageid_client.go b/sdk/storage/azqueue/generated/zz_messageid_client.go index 17c64f93251e..4ca438d95364 100644 --- a/sdk/storage/azqueue/generated/zz_messageid_client.go +++ b/sdk/storage/azqueue/generated/zz_messageid_client.go @@ -11,13 +11,10 @@ package generated import ( "context" - "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" - "net/url" "strconv" - "strings" "time" ) @@ -42,13 +39,11 @@ func NewMessageIDClient(endpoint string, pl runtime.Pipeline) *MessageIDClient { // Delete - The Delete operation deletes the specified message. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2018-03-28 -// queueName - The queue name. -// messageid - The container name. // popReceipt - Required. Specifies the valid pop receipt value returned from an earlier call to the Get Messages or Update // Message operation. // options - MessageIDClientDeleteOptions contains the optional parameters for the MessageIDClient.Delete method. -func (client *MessageIDClient) Delete(ctx context.Context, queueName string, messageid string, popReceipt string, options *MessageIDClientDeleteOptions) (MessageIDClientDeleteResponse, error) { - req, err := client.deleteCreateRequest(ctx, queueName, messageid, popReceipt, options) +func (client *MessageIDClient) Delete(ctx context.Context, popReceipt string, options *MessageIDClientDeleteOptions) (MessageIDClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, popReceipt, options) if err != nil { return MessageIDClientDeleteResponse{}, err } @@ -63,17 +58,8 @@ func (client *MessageIDClient) Delete(ctx context.Context, queueName string, mes } // deleteCreateRequest creates the Delete request. -func (client *MessageIDClient) deleteCreateRequest(ctx context.Context, queueName string, messageid string, popReceipt string, options *MessageIDClientDeleteOptions) (*policy.Request, error) { - urlPath := "/{queueName}/messages/{messageid}" - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - if messageid == "" { - return nil, errors.New("parameter messageid cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{messageid}", url.PathEscape(messageid)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.endpoint, urlPath)) +func (client *MessageIDClient) deleteCreateRequest(ctx context.Context, popReceipt string, options *MessageIDClientDeleteOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodDelete, client.endpoint) if err != nil { return nil, err } @@ -116,8 +102,6 @@ func (client *MessageIDClient) deleteHandleResponse(resp *http.Response) (Messag // and the encoded message can be up to 64KB in size. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2018-03-28 -// queueName - The queue name. -// messageid - The container name. // popReceipt - Required. Specifies the valid pop receipt value returned from an earlier call to the Get Messages or Update // Message operation. // visibilitytimeout - Optional. Specifies the new visibility timeout value, in seconds, relative to server time. The default @@ -126,8 +110,8 @@ func (client *MessageIDClient) deleteHandleResponse(resp *http.Response) (Messag // of a message can be set to a value later than the expiry time. // queueMessage - A Message object which can be stored in a Queue // options - MessageIDClientUpdateOptions contains the optional parameters for the MessageIDClient.Update method. -func (client *MessageIDClient) Update(ctx context.Context, queueName string, messageid string, popReceipt string, visibilitytimeout int32, queueMessage QueueMessage, options *MessageIDClientUpdateOptions) (MessageIDClientUpdateResponse, error) { - req, err := client.updateCreateRequest(ctx, queueName, messageid, popReceipt, visibilitytimeout, queueMessage, options) +func (client *MessageIDClient) Update(ctx context.Context, popReceipt string, visibilitytimeout int32, queueMessage QueueMessage, options *MessageIDClientUpdateOptions) (MessageIDClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, popReceipt, visibilitytimeout, queueMessage, options) if err != nil { return MessageIDClientUpdateResponse{}, err } @@ -142,17 +126,8 @@ func (client *MessageIDClient) Update(ctx context.Context, queueName string, mes } // updateCreateRequest creates the Update request. -func (client *MessageIDClient) updateCreateRequest(ctx context.Context, queueName string, messageid string, popReceipt string, visibilitytimeout int32, queueMessage QueueMessage, options *MessageIDClientUpdateOptions) (*policy.Request, error) { - urlPath := "/{queueName}/messages/{messageid}" - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - if messageid == "" { - return nil, errors.New("parameter messageid cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{messageid}", url.PathEscape(messageid)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.endpoint, urlPath)) +func (client *MessageIDClient) updateCreateRequest(ctx context.Context, popReceipt string, visibilitytimeout int32, queueMessage QueueMessage, options *MessageIDClientUpdateOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) if err != nil { return nil, err } diff --git a/sdk/storage/azqueue/generated/zz_messages_client.go b/sdk/storage/azqueue/generated/zz_messages_client.go index 0fc3331572e1..cde60d45c159 100644 --- a/sdk/storage/azqueue/generated/zz_messages_client.go +++ b/sdk/storage/azqueue/generated/zz_messages_client.go @@ -11,13 +11,10 @@ package generated import ( "context" - "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" - "net/url" "strconv" - "strings" "time" ) @@ -42,10 +39,9 @@ func NewMessagesClient(endpoint string, pl runtime.Pipeline) *MessagesClient { // Clear - The Clear operation deletes all messages from the specified queue. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2018-03-28 -// queueName - The queue name. // options - MessagesClientClearOptions contains the optional parameters for the MessagesClient.Clear method. -func (client *MessagesClient) Clear(ctx context.Context, queueName string, options *MessagesClientClearOptions) (MessagesClientClearResponse, error) { - req, err := client.clearCreateRequest(ctx, queueName, options) +func (client *MessagesClient) Clear(ctx context.Context, options *MessagesClientClearOptions) (MessagesClientClearResponse, error) { + req, err := client.clearCreateRequest(ctx, options) if err != nil { return MessagesClientClearResponse{}, err } @@ -60,13 +56,8 @@ func (client *MessagesClient) Clear(ctx context.Context, queueName string, optio } // clearCreateRequest creates the Clear request. -func (client *MessagesClient) clearCreateRequest(ctx context.Context, queueName string, options *MessagesClientClearOptions) (*policy.Request, error) { - urlPath := "/{queueName}/messages" - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.endpoint, urlPath)) +func (client *MessagesClient) clearCreateRequest(ctx context.Context, options *MessagesClientClearOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodDelete, client.endpoint) if err != nil { return nil, err } @@ -105,10 +96,9 @@ func (client *MessagesClient) clearHandleResponse(resp *http.Response) (Messages // Dequeue - The Dequeue operation retrieves one or more messages from the front of the queue. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2018-03-28 -// queueName - The queue name. // options - MessagesClientDequeueOptions contains the optional parameters for the MessagesClient.Dequeue method. -func (client *MessagesClient) Dequeue(ctx context.Context, queueName string, options *MessagesClientDequeueOptions) (MessagesClientDequeueResponse, error) { - req, err := client.dequeueCreateRequest(ctx, queueName, options) +func (client *MessagesClient) Dequeue(ctx context.Context, options *MessagesClientDequeueOptions) (MessagesClientDequeueResponse, error) { + req, err := client.dequeueCreateRequest(ctx, options) if err != nil { return MessagesClientDequeueResponse{}, err } @@ -123,13 +113,8 @@ func (client *MessagesClient) Dequeue(ctx context.Context, queueName string, opt } // dequeueCreateRequest creates the Dequeue request. -func (client *MessagesClient) dequeueCreateRequest(ctx context.Context, queueName string, options *MessagesClientDequeueOptions) (*policy.Request, error) { - urlPath := "/{queueName}/messages" - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) +func (client *MessagesClient) dequeueCreateRequest(ctx context.Context, options *MessagesClientDequeueOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodGet, client.endpoint) if err != nil { return nil, err } @@ -180,11 +165,10 @@ func (client *MessagesClient) dequeueHandleResponse(resp *http.Response) (Messag // for versions 2011-08-18 and newer, or 8 KB in size for previous versions. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2018-03-28 -// queueName - The queue name. // queueMessage - A Message object which can be stored in a Queue // options - MessagesClientEnqueueOptions contains the optional parameters for the MessagesClient.Enqueue method. -func (client *MessagesClient) Enqueue(ctx context.Context, queueName string, queueMessage QueueMessage, options *MessagesClientEnqueueOptions) (MessagesClientEnqueueResponse, error) { - req, err := client.enqueueCreateRequest(ctx, queueName, queueMessage, options) +func (client *MessagesClient) Enqueue(ctx context.Context, queueMessage QueueMessage, options *MessagesClientEnqueueOptions) (MessagesClientEnqueueResponse, error) { + req, err := client.enqueueCreateRequest(ctx, queueMessage, options) if err != nil { return MessagesClientEnqueueResponse{}, err } @@ -199,13 +183,8 @@ func (client *MessagesClient) Enqueue(ctx context.Context, queueName string, que } // enqueueCreateRequest creates the Enqueue request. -func (client *MessagesClient) enqueueCreateRequest(ctx context.Context, queueName string, queueMessage QueueMessage, options *MessagesClientEnqueueOptions) (*policy.Request, error) { - urlPath := "/{queueName}/messages" - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.endpoint, urlPath)) +func (client *MessagesClient) enqueueCreateRequest(ctx context.Context, queueMessage QueueMessage, options *MessagesClientEnqueueOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodPost, client.endpoint) if err != nil { return nil, err } @@ -254,10 +233,9 @@ func (client *MessagesClient) enqueueHandleResponse(resp *http.Response) (Messag // of the message. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2018-03-28 -// queueName - The queue name. // options - MessagesClientPeekOptions contains the optional parameters for the MessagesClient.Peek method. -func (client *MessagesClient) Peek(ctx context.Context, queueName string, options *MessagesClientPeekOptions) (MessagesClientPeekResponse, error) { - req, err := client.peekCreateRequest(ctx, queueName, options) +func (client *MessagesClient) Peek(ctx context.Context, options *MessagesClientPeekOptions) (MessagesClientPeekResponse, error) { + req, err := client.peekCreateRequest(ctx, options) if err != nil { return MessagesClientPeekResponse{}, err } @@ -272,13 +250,8 @@ func (client *MessagesClient) Peek(ctx context.Context, queueName string, option } // peekCreateRequest creates the Peek request. -func (client *MessagesClient) peekCreateRequest(ctx context.Context, queueName string, options *MessagesClientPeekOptions) (*policy.Request, error) { - urlPath := "/{queueName}/messages" - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) +func (client *MessagesClient) peekCreateRequest(ctx context.Context, options *MessagesClientPeekOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodGet, client.endpoint) if err != nil { return nil, err } diff --git a/sdk/storage/azqueue/generated/zz_queue_client.go b/sdk/storage/azqueue/generated/zz_queue_client.go index d8b34d1b881d..1b14000267ef 100644 --- a/sdk/storage/azqueue/generated/zz_queue_client.go +++ b/sdk/storage/azqueue/generated/zz_queue_client.go @@ -12,11 +12,9 @@ package generated import ( "context" "encoding/xml" - "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" - "net/url" "strconv" "strings" "time" @@ -43,10 +41,9 @@ func NewQueueClient(endpoint string, pl runtime.Pipeline) *QueueClient { // Create - creates a new queue under the given account. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2018-03-28 -// queueName - The queue name. // options - QueueClientCreateOptions contains the optional parameters for the QueueClient.Create method. -func (client *QueueClient) Create(ctx context.Context, queueName string, options *QueueClientCreateOptions) (QueueClientCreateResponse, error) { - req, err := client.createCreateRequest(ctx, queueName, options) +func (client *QueueClient) Create(ctx context.Context, options *QueueClientCreateOptions) (QueueClientCreateResponse, error) { + req, err := client.createCreateRequest(ctx, options) if err != nil { return QueueClientCreateResponse{}, err } @@ -61,13 +58,8 @@ func (client *QueueClient) Create(ctx context.Context, queueName string, options } // createCreateRequest creates the Create request. -func (client *QueueClient) createCreateRequest(ctx context.Context, queueName string, options *QueueClientCreateOptions) (*policy.Request, error) { - urlPath := "/{queueName}" - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.endpoint, urlPath)) +func (client *QueueClient) createCreateRequest(ctx context.Context, options *QueueClientCreateOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) if err != nil { return nil, err } @@ -111,10 +103,9 @@ func (client *QueueClient) createHandleResponse(resp *http.Response) (QueueClien // Delete - operation permanently deletes the specified queue // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2018-03-28 -// queueName - The queue name. // options - QueueClientDeleteOptions contains the optional parameters for the QueueClient.Delete method. -func (client *QueueClient) Delete(ctx context.Context, queueName string, options *QueueClientDeleteOptions) (QueueClientDeleteResponse, error) { - req, err := client.deleteCreateRequest(ctx, queueName, options) +func (client *QueueClient) Delete(ctx context.Context, options *QueueClientDeleteOptions) (QueueClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, options) if err != nil { return QueueClientDeleteResponse{}, err } @@ -129,13 +120,8 @@ func (client *QueueClient) Delete(ctx context.Context, queueName string, options } // deleteCreateRequest creates the Delete request. -func (client *QueueClient) deleteCreateRequest(ctx context.Context, queueName string, options *QueueClientDeleteOptions) (*policy.Request, error) { - urlPath := "/{queueName}" - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.endpoint, urlPath)) +func (client *QueueClient) deleteCreateRequest(ctx context.Context, options *QueueClientDeleteOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodDelete, client.endpoint) if err != nil { return nil, err } @@ -175,10 +161,9 @@ func (client *QueueClient) deleteHandleResponse(resp *http.Response) (QueueClien // Access Signatures. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2018-03-28 -// queueName - The queue name. // options - QueueClientGetAccessPolicyOptions contains the optional parameters for the QueueClient.GetAccessPolicy method. -func (client *QueueClient) GetAccessPolicy(ctx context.Context, queueName string, options *QueueClientGetAccessPolicyOptions) (QueueClientGetAccessPolicyResponse, error) { - req, err := client.getAccessPolicyCreateRequest(ctx, queueName, options) +func (client *QueueClient) GetAccessPolicy(ctx context.Context, options *QueueClientGetAccessPolicyOptions) (QueueClientGetAccessPolicyResponse, error) { + req, err := client.getAccessPolicyCreateRequest(ctx, options) if err != nil { return QueueClientGetAccessPolicyResponse{}, err } @@ -193,13 +178,8 @@ func (client *QueueClient) GetAccessPolicy(ctx context.Context, queueName string } // getAccessPolicyCreateRequest creates the GetAccessPolicy request. -func (client *QueueClient) getAccessPolicyCreateRequest(ctx context.Context, queueName string, options *QueueClientGetAccessPolicyOptions) (*policy.Request, error) { - urlPath := "/{queueName}" - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) +func (client *QueueClient) getAccessPolicyCreateRequest(ctx context.Context, options *QueueClientGetAccessPolicyOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodGet, client.endpoint) if err != nil { return nil, err } @@ -243,10 +223,9 @@ func (client *QueueClient) getAccessPolicyHandleResponse(resp *http.Response) (Q // the queue as name-values pairs. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2018-03-28 -// queueName - The queue name. // options - QueueClientGetPropertiesOptions contains the optional parameters for the QueueClient.GetProperties method. -func (client *QueueClient) GetProperties(ctx context.Context, queueName string, options *QueueClientGetPropertiesOptions) (QueueClientGetPropertiesResponse, error) { - req, err := client.getPropertiesCreateRequest(ctx, queueName, options) +func (client *QueueClient) GetProperties(ctx context.Context, options *QueueClientGetPropertiesOptions) (QueueClientGetPropertiesResponse, error) { + req, err := client.getPropertiesCreateRequest(ctx, options) if err != nil { return QueueClientGetPropertiesResponse{}, err } @@ -261,13 +240,8 @@ func (client *QueueClient) GetProperties(ctx context.Context, queueName string, } // getPropertiesCreateRequest creates the GetProperties request. -func (client *QueueClient) getPropertiesCreateRequest(ctx context.Context, queueName string, options *QueueClientGetPropertiesOptions) (*policy.Request, error) { - urlPath := "/{queueName}" - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.endpoint, urlPath)) +func (client *QueueClient) getPropertiesCreateRequest(ctx context.Context, options *QueueClientGetPropertiesOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodGet, client.endpoint) if err != nil { return nil, err } @@ -323,11 +297,10 @@ func (client *QueueClient) getPropertiesHandleResponse(resp *http.Response) (Que // SetAccessPolicy - sets stored access policies for the queue that may be used with Shared Access Signatures // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2018-03-28 -// queueName - The queue name. // queueACL - the acls for the queue // options - QueueClientSetAccessPolicyOptions contains the optional parameters for the QueueClient.SetAccessPolicy method. -func (client *QueueClient) SetAccessPolicy(ctx context.Context, queueName string, queueACL []*SignedIdentifier, options *QueueClientSetAccessPolicyOptions) (QueueClientSetAccessPolicyResponse, error) { - req, err := client.setAccessPolicyCreateRequest(ctx, queueName, queueACL, options) +func (client *QueueClient) SetAccessPolicy(ctx context.Context, queueACL []*SignedIdentifier, options *QueueClientSetAccessPolicyOptions) (QueueClientSetAccessPolicyResponse, error) { + req, err := client.setAccessPolicyCreateRequest(ctx, queueACL, options) if err != nil { return QueueClientSetAccessPolicyResponse{}, err } @@ -342,13 +315,8 @@ func (client *QueueClient) SetAccessPolicy(ctx context.Context, queueName string } // setAccessPolicyCreateRequest creates the SetAccessPolicy request. -func (client *QueueClient) setAccessPolicyCreateRequest(ctx context.Context, queueName string, queueACL []*SignedIdentifier, options *QueueClientSetAccessPolicyOptions) (*policy.Request, error) { - urlPath := "/{queueName}" - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.endpoint, urlPath)) +func (client *QueueClient) setAccessPolicyCreateRequest(ctx context.Context, queueACL []*SignedIdentifier, options *QueueClientSetAccessPolicyOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) if err != nil { return nil, err } @@ -392,10 +360,9 @@ func (client *QueueClient) setAccessPolicyHandleResponse(resp *http.Response) (Q // SetMetadata - sets user-defined metadata on the specified queue. Metadata is associated with the queue as name-value pairs. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2018-03-28 -// queueName - The queue name. // options - QueueClientSetMetadataOptions contains the optional parameters for the QueueClient.SetMetadata method. -func (client *QueueClient) SetMetadata(ctx context.Context, queueName string, options *QueueClientSetMetadataOptions) (QueueClientSetMetadataResponse, error) { - req, err := client.setMetadataCreateRequest(ctx, queueName, options) +func (client *QueueClient) SetMetadata(ctx context.Context, options *QueueClientSetMetadataOptions) (QueueClientSetMetadataResponse, error) { + req, err := client.setMetadataCreateRequest(ctx, options) if err != nil { return QueueClientSetMetadataResponse{}, err } @@ -410,13 +377,8 @@ func (client *QueueClient) SetMetadata(ctx context.Context, queueName string, op } // setMetadataCreateRequest creates the SetMetadata request. -func (client *QueueClient) setMetadataCreateRequest(ctx context.Context, queueName string, options *QueueClientSetMetadataOptions) (*policy.Request, error) { - urlPath := "/{queueName}" - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.endpoint, urlPath)) +func (client *QueueClient) setMetadataCreateRequest(ctx context.Context, options *QueueClientSetMetadataOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) if err != nil { return nil, err } diff --git a/sdk/storage/azqueue/go.mod b/sdk/storage/azqueue/go.mod new file mode 100644 index 000000000000..8a24f5064305 --- /dev/null +++ b/sdk/storage/azqueue/go.mod @@ -0,0 +1,11 @@ +module github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue + +go 1.19 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/sdk/storage/azqueue/go.sum b/sdk/storage/azqueue/go.sum new file mode 100644 index 000000000000..433d69b57a0d --- /dev/null +++ b/sdk/storage/azqueue/go.sum @@ -0,0 +1,12 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0 h1:sVW/AFBTGyJxDaMYlq0ct3jUXTtj12tQ6zE2GZUgVQw= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= diff --git a/sdk/storage/azqueue/internal/autorest.md b/sdk/storage/azqueue/internal/autorest.md index 1052245bcbfa..98464c360d92 100644 --- a/sdk/storage/azqueue/internal/autorest.md +++ b/sdk/storage/azqueue/internal/autorest.md @@ -21,3 +21,32 @@ modelerfour: export-clients: true use: "@autorest/go@4.0.0-preview.43" ``` + + +### Remove QueueName from parameter list since it is not needed +``` yaml +directive: +- from: swagger-document + where: $["x-ms-paths"] + transform: > + for (const property in $) + { + if (property.includes('/{queueName}/messages/{messageid}')) + { + $[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/QueueName") && false == param['$ref'].endsWith("#/parameters/MessageId"))}); + } + else if (property.includes('/{queueName}')) + { + $[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/QueueName"))}); + } + } +``` + +### QueueMessage is required for enqueue, but not for update +``` yaml +directive: +- from: swagger-document + where: $.parameters.QueueMessage + transform: > + $.required = false; +``` \ No newline at end of file From 905b59505e3ab21081cef2a3f62ea19d41b75731 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Tue, 27 Dec 2022 14:36:19 -0800 Subject: [PATCH 03/17] fixed georep --- sdk/storage/azqueue/generated/zz_constants.go | 22 +++++++++---------- sdk/storage/azqueue/generated/zz_models.go | 2 +- sdk/storage/azqueue/internal/autorest.md | 11 +++++++--- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/sdk/storage/azqueue/generated/zz_constants.go b/sdk/storage/azqueue/generated/zz_constants.go index a680dbaafecb..ea5e119d0ab1 100644 --- a/sdk/storage/azqueue/generated/zz_constants.go +++ b/sdk/storage/azqueue/generated/zz_constants.go @@ -9,21 +9,21 @@ package generated -// GeoReplicationStatusType - The status of the secondary location -type GeoReplicationStatusType string +// QueueGeoReplicationStatus - The status of the secondary location +type QueueGeoReplicationStatus string const ( - GeoReplicationStatusTypeBootstrap GeoReplicationStatusType = "bootstrap" - GeoReplicationStatusTypeLive GeoReplicationStatusType = "live" - GeoReplicationStatusTypeUnavailable GeoReplicationStatusType = "unavailable" + QueueGeoReplicationStatusLive QueueGeoReplicationStatus = "live" + QueueGeoReplicationStatusBootstrap QueueGeoReplicationStatus = "bootstrap" + QueueGeoReplicationStatusUnavailable QueueGeoReplicationStatus = "unavailable" ) -// PossibleGeoReplicationStatusTypeValues returns the possible values for the GeoReplicationStatusType const type. -func PossibleGeoReplicationStatusTypeValues() []GeoReplicationStatusType { - return []GeoReplicationStatusType{ - GeoReplicationStatusTypeBootstrap, - GeoReplicationStatusTypeLive, - GeoReplicationStatusTypeUnavailable, +// PossibleQueueGeoReplicationStatusValues returns the possible values for the QueueGeoReplicationStatus const type. +func PossibleQueueGeoReplicationStatusValues() []QueueGeoReplicationStatus { + return []QueueGeoReplicationStatus{ + QueueGeoReplicationStatusLive, + QueueGeoReplicationStatusBootstrap, + QueueGeoReplicationStatusUnavailable, } } diff --git a/sdk/storage/azqueue/generated/zz_models.go b/sdk/storage/azqueue/generated/zz_models.go index eda90fa9c48e..a58cf599fe83 100644 --- a/sdk/storage/azqueue/generated/zz_models.go +++ b/sdk/storage/azqueue/generated/zz_models.go @@ -99,7 +99,7 @@ type GeoReplication struct { LastSyncTime *time.Time `xml:"LastSyncTime"` // REQUIRED; The status of the secondary location - Status *GeoReplicationStatusType `xml:"Status"` + Status *QueueGeoReplicationStatus `xml:"Status"` } // ListQueuesSegmentResponse - The object returned when calling List Queues on a Queue Service. diff --git a/sdk/storage/azqueue/internal/autorest.md b/sdk/storage/azqueue/internal/autorest.md index 98464c360d92..d5dec1ab5ad5 100644 --- a/sdk/storage/azqueue/internal/autorest.md +++ b/sdk/storage/azqueue/internal/autorest.md @@ -42,11 +42,16 @@ directive: } ``` -### QueueMessage is required for enqueue, but not for update +### Fix GeoReplication + ``` yaml directive: - from: swagger-document - where: $.parameters.QueueMessage + where: $.definitions transform: > - $.required = false; + delete $.GeoReplication.properties.Status["x-ms-enum"]; + $.GeoReplication.properties.Status["x-ms-enum"] = { + "name": "QueueGeoReplicationStatus", + "modelAsString": false + }; ``` \ No newline at end of file From edf58cd2ae0f7bf390e98e134322edf09bc3fe38 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Tue, 27 Dec 2022 15:11:42 -0800 Subject: [PATCH 04/17] removed pagination --- .../azqueue/generated/zz_service_client.go | 34 ++----------------- sdk/storage/azqueue/internal/autorest.md | 13 +++++++ 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/sdk/storage/azqueue/generated/zz_service_client.go b/sdk/storage/azqueue/generated/zz_service_client.go index c426f66bd783..1ef56fbb8397 100644 --- a/sdk/storage/azqueue/generated/zz_service_client.go +++ b/sdk/storage/azqueue/generated/zz_service_client.go @@ -163,36 +163,8 @@ func (client *ServiceClient) getStatisticsHandleResponse(resp *http.Response) (S // Generated from API version 2018-03-28 // options - ServiceClientListQueuesSegmentOptions contains the optional parameters for the ServiceClient.ListQueuesSegment // method. -func (client *ServiceClient) NewListQueuesSegmentPager(options *ServiceClientListQueuesSegmentOptions) (*runtime.Pager[ServiceClientListQueuesSegmentResponse]) { - return runtime.NewPager(runtime.PagingHandler[ServiceClientListQueuesSegmentResponse]{ - More: func(page ServiceClientListQueuesSegmentResponse) bool { - return page.NextMarker != nil && len(*page.NextMarker) > 0 - }, - Fetcher: func(ctx context.Context, page *ServiceClientListQueuesSegmentResponse) (ServiceClientListQueuesSegmentResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listQueuesSegmentCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextMarker) - } - if err != nil { - return ServiceClientListQueuesSegmentResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return ServiceClientListQueuesSegmentResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ServiceClientListQueuesSegmentResponse{}, runtime.NewResponseError(resp) - } - return client.listQueuesSegmentHandleResponse(resp) - }, - }) -} - -// listQueuesSegmentCreateRequest creates the ListQueuesSegment request. -func (client *ServiceClient) listQueuesSegmentCreateRequest(ctx context.Context, options *ServiceClientListQueuesSegmentOptions) (*policy.Request, error) { +// ListQueuesSegmentCreateRequest creates the ListBlobFlatSegment ListQueuesSegment. +func (client *ServiceClient) ListQueuesSegmentCreateRequest(ctx context.Context, options *ServiceClientListQueuesSegmentOptions) (*policy.Request, error) { req, err := runtime.NewRequest(ctx, http.MethodGet, client.endpoint) if err != nil { return nil, err @@ -224,7 +196,7 @@ func (client *ServiceClient) listQueuesSegmentCreateRequest(ctx context.Context, } // listQueuesSegmentHandleResponse handles the ListQueuesSegment response. -func (client *ServiceClient) listQueuesSegmentHandleResponse(resp *http.Response) (ServiceClientListQueuesSegmentResponse, error) { +func (client *ServiceClient) ListQueuesSegmentHandleResponse(resp *http.Response) (ServiceClientListQueuesSegmentResponse, error) { result := ServiceClientListQueuesSegmentResponse{} if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val diff --git a/sdk/storage/azqueue/internal/autorest.md b/sdk/storage/azqueue/internal/autorest.md index d5dec1ab5ad5..1af83342c0cf 100644 --- a/sdk/storage/azqueue/internal/autorest.md +++ b/sdk/storage/azqueue/internal/autorest.md @@ -54,4 +54,17 @@ directive: "name": "QueueGeoReplicationStatus", "modelAsString": false }; +``` + +### Remove pager method (since we implement it ourselves on the client layer) and export various generated methods in service client to utilize them in higher layers + +``` yaml +directive: + - from: zz_service_client.go + where: $ + transform: >- + return $. + replace(/func \(client \*ServiceClient\) NewListQueuesSegmentPager\(.+\/\/ listQueuesSegmentCreateRequest creates the ListQueuesSegment request/s, `// ListQueuesSegmentCreateRequest creates the ListBlobFlatSegment ListQueuesSegment`). + replace(/\(client \*ServiceClient\) listQueuesSegmentCreateRequest\(/, `(client *ServiceClient) ListQueuesSegmentCreateRequest(`). + replace(/\(client \*ServiceClient\) listQueuesSegmentHandleResponse\(/, `(client *ServiceClient) ListQueuesSegmentHandleResponse(`); ``` \ No newline at end of file From 3b32383ac27fd23361ce18334dee26cd9a253b01 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Tue, 27 Dec 2022 15:50:35 -0800 Subject: [PATCH 05/17] added basic methods --- sdk/storage/azqueue/generated/zz_constants.go | 155 ------------- sdk/storage/azqueue/internal/base/clients.go | 65 ++++++ .../exported/shared_key_credential.go | 218 ++++++++++++++++++ .../internal/{ => generated}/autorest.md | 0 .../internal/generated/zz_constants.go | 154 +++++++++++++ .../generated/zz_messageid_client.go | 0 .../generated/zz_messages_client.go | 0 .../{ => internal}/generated/zz_models.go | 113 +++++---- .../generated/zz_models_serde.go | 51 ++-- .../generated/zz_queue_client.go | 7 +- .../generated/zz_response_types.go | 0 .../generated/zz_service_client.go | 0 .../generated/zz_time_rfc1123.go | 0 .../generated/zz_time_rfc3339.go | 0 .../{ => internal}/generated/zz_xml_helper.go | 0 sdk/storage/azqueue/internal/shared/shared.go | 146 ++++++++++++ 16 files changed, 667 insertions(+), 242 deletions(-) delete mode 100644 sdk/storage/azqueue/generated/zz_constants.go create mode 100644 sdk/storage/azqueue/internal/base/clients.go create mode 100644 sdk/storage/azqueue/internal/exported/shared_key_credential.go rename sdk/storage/azqueue/internal/{ => generated}/autorest.md (100%) create mode 100644 sdk/storage/azqueue/internal/generated/zz_constants.go rename sdk/storage/azqueue/{ => internal}/generated/zz_messageid_client.go (100%) rename sdk/storage/azqueue/{ => internal}/generated/zz_messages_client.go (100%) rename sdk/storage/azqueue/{ => internal}/generated/zz_models.go (81%) rename sdk/storage/azqueue/{ => internal}/generated/zz_models_serde.go (86%) rename sdk/storage/azqueue/{ => internal}/generated/zz_queue_client.go (99%) rename sdk/storage/azqueue/{ => internal}/generated/zz_response_types.go (100%) rename sdk/storage/azqueue/{ => internal}/generated/zz_service_client.go (100%) rename sdk/storage/azqueue/{ => internal}/generated/zz_time_rfc1123.go (100%) rename sdk/storage/azqueue/{ => internal}/generated/zz_time_rfc3339.go (100%) rename sdk/storage/azqueue/{ => internal}/generated/zz_xml_helper.go (100%) create mode 100644 sdk/storage/azqueue/internal/shared/shared.go diff --git a/sdk/storage/azqueue/generated/zz_constants.go b/sdk/storage/azqueue/generated/zz_constants.go deleted file mode 100644 index ea5e119d0ab1..000000000000 --- a/sdk/storage/azqueue/generated/zz_constants.go +++ /dev/null @@ -1,155 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package generated - -// QueueGeoReplicationStatus - The status of the secondary location -type QueueGeoReplicationStatus string - -const ( - QueueGeoReplicationStatusLive QueueGeoReplicationStatus = "live" - QueueGeoReplicationStatusBootstrap QueueGeoReplicationStatus = "bootstrap" - QueueGeoReplicationStatusUnavailable QueueGeoReplicationStatus = "unavailable" -) - -// PossibleQueueGeoReplicationStatusValues returns the possible values for the QueueGeoReplicationStatus const type. -func PossibleQueueGeoReplicationStatusValues() []QueueGeoReplicationStatus { - return []QueueGeoReplicationStatus{ - QueueGeoReplicationStatusLive, - QueueGeoReplicationStatusBootstrap, - QueueGeoReplicationStatusUnavailable, - } -} - -// StorageErrorCode - Error codes returned by the service -type StorageErrorCode string - -const ( - StorageErrorCodeAccountAlreadyExists StorageErrorCode = "AccountAlreadyExists" - StorageErrorCodeAccountBeingCreated StorageErrorCode = "AccountBeingCreated" - StorageErrorCodeAccountIsDisabled StorageErrorCode = "AccountIsDisabled" - StorageErrorCodeAuthenticationFailed StorageErrorCode = "AuthenticationFailed" - StorageErrorCodeAuthorizationFailure StorageErrorCode = "AuthorizationFailure" - StorageErrorCodeAuthorizationPermissionMismatch StorageErrorCode = "AuthorizationPermissionMismatch" - StorageErrorCodeAuthorizationProtocolMismatch StorageErrorCode = "AuthorizationProtocolMismatch" - StorageErrorCodeAuthorizationResourceTypeMismatch StorageErrorCode = "AuthorizationResourceTypeMismatch" - StorageErrorCodeAuthorizationServiceMismatch StorageErrorCode = "AuthorizationServiceMismatch" - StorageErrorCodeAuthorizationSourceIPMismatch StorageErrorCode = "AuthorizationSourceIPMismatch" - StorageErrorCodeConditionHeadersNotSupported StorageErrorCode = "ConditionHeadersNotSupported" - StorageErrorCodeConditionNotMet StorageErrorCode = "ConditionNotMet" - StorageErrorCodeEmptyMetadataKey StorageErrorCode = "EmptyMetadataKey" - StorageErrorCodeFeatureVersionMismatch StorageErrorCode = "FeatureVersionMismatch" - StorageErrorCodeInsufficientAccountPermissions StorageErrorCode = "InsufficientAccountPermissions" - StorageErrorCodeInternalError StorageErrorCode = "InternalError" - StorageErrorCodeInvalidAuthenticationInfo StorageErrorCode = "InvalidAuthenticationInfo" - StorageErrorCodeInvalidHTTPVerb StorageErrorCode = "InvalidHttpVerb" - StorageErrorCodeInvalidHeaderValue StorageErrorCode = "InvalidHeaderValue" - StorageErrorCodeInvalidInput StorageErrorCode = "InvalidInput" - StorageErrorCodeInvalidMD5 StorageErrorCode = "InvalidMd5" - StorageErrorCodeInvalidMarker StorageErrorCode = "InvalidMarker" - StorageErrorCodeInvalidMetadata StorageErrorCode = "InvalidMetadata" - StorageErrorCodeInvalidQueryParameterValue StorageErrorCode = "InvalidQueryParameterValue" - StorageErrorCodeInvalidRange StorageErrorCode = "InvalidRange" - StorageErrorCodeInvalidResourceName StorageErrorCode = "InvalidResourceName" - StorageErrorCodeInvalidURI StorageErrorCode = "InvalidUri" - StorageErrorCodeInvalidXMLDocument StorageErrorCode = "InvalidXmlDocument" - StorageErrorCodeInvalidXMLNodeValue StorageErrorCode = "InvalidXmlNodeValue" - StorageErrorCodeMD5Mismatch StorageErrorCode = "Md5Mismatch" - StorageErrorCodeMessageNotFound StorageErrorCode = "MessageNotFound" - StorageErrorCodeMessageTooLarge StorageErrorCode = "MessageTooLarge" - StorageErrorCodeMetadataTooLarge StorageErrorCode = "MetadataTooLarge" - StorageErrorCodeMissingContentLengthHeader StorageErrorCode = "MissingContentLengthHeader" - StorageErrorCodeMissingRequiredHeader StorageErrorCode = "MissingRequiredHeader" - StorageErrorCodeMissingRequiredQueryParameter StorageErrorCode = "MissingRequiredQueryParameter" - StorageErrorCodeMissingRequiredXMLNode StorageErrorCode = "MissingRequiredXmlNode" - StorageErrorCodeMultipleConditionHeadersNotSupported StorageErrorCode = "MultipleConditionHeadersNotSupported" - StorageErrorCodeOperationTimedOut StorageErrorCode = "OperationTimedOut" - StorageErrorCodeOutOfRangeInput StorageErrorCode = "OutOfRangeInput" - StorageErrorCodeOutOfRangeQueryParameterValue StorageErrorCode = "OutOfRangeQueryParameterValue" - StorageErrorCodePopReceiptMismatch StorageErrorCode = "PopReceiptMismatch" - StorageErrorCodeQueueAlreadyExists StorageErrorCode = "QueueAlreadyExists" - StorageErrorCodeQueueBeingDeleted StorageErrorCode = "QueueBeingDeleted" - StorageErrorCodeQueueDisabled StorageErrorCode = "QueueDisabled" - StorageErrorCodeQueueNotEmpty StorageErrorCode = "QueueNotEmpty" - StorageErrorCodeQueueNotFound StorageErrorCode = "QueueNotFound" - StorageErrorCodeRequestBodyTooLarge StorageErrorCode = "RequestBodyTooLarge" - StorageErrorCodeRequestURLFailedToParse StorageErrorCode = "RequestUrlFailedToParse" - StorageErrorCodeResourceAlreadyExists StorageErrorCode = "ResourceAlreadyExists" - StorageErrorCodeResourceNotFound StorageErrorCode = "ResourceNotFound" - StorageErrorCodeResourceTypeMismatch StorageErrorCode = "ResourceTypeMismatch" - StorageErrorCodeServerBusy StorageErrorCode = "ServerBusy" - StorageErrorCodeUnsupportedHTTPVerb StorageErrorCode = "UnsupportedHttpVerb" - StorageErrorCodeUnsupportedHeader StorageErrorCode = "UnsupportedHeader" - StorageErrorCodeUnsupportedQueryParameter StorageErrorCode = "UnsupportedQueryParameter" - StorageErrorCodeUnsupportedXMLNode StorageErrorCode = "UnsupportedXmlNode" -) - -// PossibleStorageErrorCodeValues returns the possible values for the StorageErrorCode const type. -func PossibleStorageErrorCodeValues() []StorageErrorCode { - return []StorageErrorCode{ - StorageErrorCodeAccountAlreadyExists, - StorageErrorCodeAccountBeingCreated, - StorageErrorCodeAccountIsDisabled, - StorageErrorCodeAuthenticationFailed, - StorageErrorCodeAuthorizationFailure, - StorageErrorCodeAuthorizationPermissionMismatch, - StorageErrorCodeAuthorizationProtocolMismatch, - StorageErrorCodeAuthorizationResourceTypeMismatch, - StorageErrorCodeAuthorizationServiceMismatch, - StorageErrorCodeAuthorizationSourceIPMismatch, - StorageErrorCodeConditionHeadersNotSupported, - StorageErrorCodeConditionNotMet, - StorageErrorCodeEmptyMetadataKey, - StorageErrorCodeFeatureVersionMismatch, - StorageErrorCodeInsufficientAccountPermissions, - StorageErrorCodeInternalError, - StorageErrorCodeInvalidAuthenticationInfo, - StorageErrorCodeInvalidHTTPVerb, - StorageErrorCodeInvalidHeaderValue, - StorageErrorCodeInvalidInput, - StorageErrorCodeInvalidMD5, - StorageErrorCodeInvalidMarker, - StorageErrorCodeInvalidMetadata, - StorageErrorCodeInvalidQueryParameterValue, - StorageErrorCodeInvalidRange, - StorageErrorCodeInvalidResourceName, - StorageErrorCodeInvalidURI, - StorageErrorCodeInvalidXMLDocument, - StorageErrorCodeInvalidXMLNodeValue, - StorageErrorCodeMD5Mismatch, - StorageErrorCodeMessageNotFound, - StorageErrorCodeMessageTooLarge, - StorageErrorCodeMetadataTooLarge, - StorageErrorCodeMissingContentLengthHeader, - StorageErrorCodeMissingRequiredHeader, - StorageErrorCodeMissingRequiredQueryParameter, - StorageErrorCodeMissingRequiredXMLNode, - StorageErrorCodeMultipleConditionHeadersNotSupported, - StorageErrorCodeOperationTimedOut, - StorageErrorCodeOutOfRangeInput, - StorageErrorCodeOutOfRangeQueryParameterValue, - StorageErrorCodePopReceiptMismatch, - StorageErrorCodeQueueAlreadyExists, - StorageErrorCodeQueueBeingDeleted, - StorageErrorCodeQueueDisabled, - StorageErrorCodeQueueNotEmpty, - StorageErrorCodeQueueNotFound, - StorageErrorCodeRequestBodyTooLarge, - StorageErrorCodeRequestURLFailedToParse, - StorageErrorCodeResourceAlreadyExists, - StorageErrorCodeResourceNotFound, - StorageErrorCodeResourceTypeMismatch, - StorageErrorCodeServerBusy, - StorageErrorCodeUnsupportedHTTPVerb, - StorageErrorCodeUnsupportedHeader, - StorageErrorCodeUnsupportedQueryParameter, - StorageErrorCodeUnsupportedXMLNode, - } -} - diff --git a/sdk/storage/azqueue/internal/base/clients.go b/sdk/storage/azqueue/internal/base/clients.go new file mode 100644 index 000000000000..27baa58d216a --- /dev/null +++ b/sdk/storage/azqueue/internal/base/clients.go @@ -0,0 +1,65 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package base + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/exported" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/generated" +) + +type Client[T any] struct { + inner *T + sharedKey *exported.SharedKeyCredential +} + +func InnerClient[T any](client *Client[T]) *T { + return client.inner +} + +func SharedKey[T any](client *Client[T]) *exported.SharedKeyCredential { + return client.sharedKey +} + +func NewClient[T any](inner *T) *Client[T] { + return &Client[T]{inner: inner} +} + +func NewServiceClient(containerURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.ServiceClient] { + return &Client[generated.ServiceClient]{ + inner: generated.NewServiceClient(containerURL, pipeline), + sharedKey: sharedKey, + } +} + +func NewQueueClient(containerURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.QueueClient] { + return &Client[generated.QueueClient]{ + inner: generated.NewQueueClient(containerURL, pipeline), + sharedKey: sharedKey, + } +} + +func NewMessagesClient(blobURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.MessagesClient] { + return &Client[generated.MessagesClient]{ + inner: generated.NewMessagesClient(blobURL, pipeline), + sharedKey: sharedKey, + } +} + +type CompositeClient[T, U any] struct { + innerT *T + innerU *U + sharedKey *exported.SharedKeyCredential +} + +func InnerClients[T, U any](client *CompositeClient[T, U]) (*Client[T], *U) { + return &Client[T]{inner: client.innerT}, client.innerU +} + +func SharedKeyComposite[T, U any](client *CompositeClient[T, U]) *exported.SharedKeyCredential { + return client.sharedKey +} diff --git a/sdk/storage/azqueue/internal/exported/shared_key_credential.go b/sdk/storage/azqueue/internal/exported/shared_key_credential.go new file mode 100644 index 000000000000..a8d648104cad --- /dev/null +++ b/sdk/storage/azqueue/internal/exported/shared_key_credential.go @@ -0,0 +1,218 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package exported + +import ( + "bytes" + "crypto/hmac" + "crypto/sha256" + "encoding/base64" + "fmt" + "net/http" + "net/url" + "sort" + "strings" + "sync/atomic" + "time" + + azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/internal/log" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/shared" +) + +// NewSharedKeyCredential creates an immutable SharedKeyCredential containing the +// storage account's name and either its primary or secondary key. +func NewSharedKeyCredential(accountName string, accountKey string) (*SharedKeyCredential, error) { + c := SharedKeyCredential{accountName: accountName} + if err := c.SetAccountKey(accountKey); err != nil { + return nil, err + } + return &c, nil +} + +// SharedKeyCredential contains an account's name and its primary or secondary key. +type SharedKeyCredential struct { + // Only the NewSharedKeyCredential method should set these; all other methods should treat them as read-only + accountName string + accountKey atomic.Value // []byte +} + +// AccountName returns the Storage account's name. +func (c *SharedKeyCredential) AccountName() string { + return c.accountName +} + +// SetAccountKey replaces the existing account key with the specified account key. +func (c *SharedKeyCredential) SetAccountKey(accountKey string) error { + _bytes, err := base64.StdEncoding.DecodeString(accountKey) + if err != nil { + return fmt.Errorf("decode account key: %w", err) + } + c.accountKey.Store(_bytes) + return nil +} + +// ComputeHMACSHA256 generates a hash signature for an HTTP request or for a SAS. +func (c *SharedKeyCredential) computeHMACSHA256(message string) (string, error) { + h := hmac.New(sha256.New, c.accountKey.Load().([]byte)) + _, err := h.Write([]byte(message)) + return base64.StdEncoding.EncodeToString(h.Sum(nil)), err +} + +func (c *SharedKeyCredential) buildStringToSign(req *http.Request) (string, error) { + // https://docs.microsoft.com/en-us/rest/api/storageservices/authentication-for-the-azure-storage-services + headers := req.Header + contentLength := getHeader(shared.HeaderContentLength, headers) + if contentLength == "0" { + contentLength = "" + } + + canonicalizedResource, err := c.buildCanonicalizedResource(req.URL) + if err != nil { + return "", err + } + + stringToSign := strings.Join([]string{ + req.Method, + getHeader(shared.HeaderContentEncoding, headers), + getHeader(shared.HeaderContentLanguage, headers), + contentLength, + getHeader(shared.HeaderContentMD5, headers), + getHeader(shared.HeaderContentType, headers), + "", // Empty date because x-ms-date is expected (as per web page above) + getHeader(shared.HeaderIfModifiedSince, headers), + getHeader(shared.HeaderIfMatch, headers), + getHeader(shared.HeaderIfNoneMatch, headers), + getHeader(shared.HeaderIfUnmodifiedSince, headers), + getHeader(shared.HeaderRange, headers), + c.buildCanonicalizedHeader(headers), + canonicalizedResource, + }, "\n") + return stringToSign, nil +} + +func getHeader(key string, headers map[string][]string) string { + if headers == nil { + return "" + } + if v, ok := headers[key]; ok { + if len(v) > 0 { + return v[0] + } + } + + return "" +} + +func (c *SharedKeyCredential) buildCanonicalizedHeader(headers http.Header) string { + cm := map[string][]string{} + for k, v := range headers { + headerName := strings.TrimSpace(strings.ToLower(k)) + if strings.HasPrefix(headerName, "x-ms-") { + cm[headerName] = v // NOTE: the value must not have any whitespace around it. + } + } + if len(cm) == 0 { + return "" + } + + keys := make([]string, 0, len(cm)) + for key := range cm { + keys = append(keys, key) + } + sort.Strings(keys) + ch := bytes.NewBufferString("") + for i, key := range keys { + if i > 0 { + ch.WriteRune('\n') + } + ch.WriteString(key) + ch.WriteRune(':') + ch.WriteString(strings.Join(cm[key], ",")) + } + return ch.String() +} + +func (c *SharedKeyCredential) buildCanonicalizedResource(u *url.URL) (string, error) { + // https://docs.microsoft.com/en-us/rest/api/storageservices/authentication-for-the-azure-storage-services + cr := bytes.NewBufferString("/") + cr.WriteString(c.accountName) + + if len(u.Path) > 0 { + // Any portion of the CanonicalizedResource string that is derived from + // the resource's URI should be encoded exactly as it is in the URI. + // -- https://msdn.microsoft.com/en-gb/library/azure/dd179428.aspx + cr.WriteString(u.EscapedPath()) + } else { + // a slash is required to indicate the root path + cr.WriteString("/") + } + + // params is a map[string][]string; param name is key; params values is []string + params, err := url.ParseQuery(u.RawQuery) // Returns URL decoded values + if err != nil { + return "", fmt.Errorf("failed to parse query params: %w", err) + } + + if len(params) > 0 { // There is at least 1 query parameter + var paramNames []string // We use this to sort the parameter key names + for paramName := range params { + paramNames = append(paramNames, paramName) // paramNames must be lowercase + } + sort.Strings(paramNames) + + for _, paramName := range paramNames { + paramValues := params[paramName] + sort.Strings(paramValues) + + // Join the sorted key values separated by ',' + // Then prepend "keyName:"; then add this string to the buffer + cr.WriteString("\n" + paramName + ":" + strings.Join(paramValues, ",")) + } + } + return cr.String(), nil +} + +// ComputeHMACSHA256 is a helper for computing the signed string outside of this package. +func ComputeHMACSHA256(cred *SharedKeyCredential, message string) (string, error) { + return cred.computeHMACSHA256(message) +} + +// the following content isn't actually exported but must live +// next to SharedKeyCredential as it uses its unexported methods + +type SharedKeyCredPolicy struct { + cred *SharedKeyCredential +} + +func NewSharedKeyCredPolicy(cred *SharedKeyCredential) *SharedKeyCredPolicy { + return &SharedKeyCredPolicy{cred: cred} +} + +func (s *SharedKeyCredPolicy) Do(req *policy.Request) (*http.Response, error) { + if d := getHeader(shared.HeaderXmsDate, req.Raw().Header); d == "" { + req.Raw().Header.Set(shared.HeaderXmsDate, time.Now().UTC().Format(http.TimeFormat)) + } + stringToSign, err := s.cred.buildStringToSign(req.Raw()) + if err != nil { + return nil, err + } + signature, err := s.cred.computeHMACSHA256(stringToSign) + if err != nil { + return nil, err + } + authHeader := strings.Join([]string{"SharedKey ", s.cred.AccountName(), ":", signature}, "") + req.Raw().Header.Set(shared.HeaderAuthorization, authHeader) + + response, err := req.Next() + if err != nil && response != nil && response.StatusCode == http.StatusForbidden { + // Service failed to authenticate request, log it + log.Write(azlog.EventResponse, "===== HTTP Forbidden status, String-to-Sign:\n"+stringToSign+"\n===============================\n") + } + return response, err +} diff --git a/sdk/storage/azqueue/internal/autorest.md b/sdk/storage/azqueue/internal/generated/autorest.md similarity index 100% rename from sdk/storage/azqueue/internal/autorest.md rename to sdk/storage/azqueue/internal/generated/autorest.md diff --git a/sdk/storage/azqueue/internal/generated/zz_constants.go b/sdk/storage/azqueue/internal/generated/zz_constants.go new file mode 100644 index 000000000000..ba7f3d01fb5c --- /dev/null +++ b/sdk/storage/azqueue/internal/generated/zz_constants.go @@ -0,0 +1,154 @@ +//go:build go1.18 +// +build go1.18 + +// 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) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package generated + +// QueueGeoReplicationStatus - The status of the secondary location +type QueueGeoReplicationStatus string + +const ( + QueueGeoReplicationStatusLive QueueGeoReplicationStatus = "live" + QueueGeoReplicationStatusBootstrap QueueGeoReplicationStatus = "bootstrap" + QueueGeoReplicationStatusUnavailable QueueGeoReplicationStatus = "unavailable" +) + +// PossibleQueueGeoReplicationStatusValues returns the possible values for the QueueGeoReplicationStatus const type. +func PossibleQueueGeoReplicationStatusValues() []QueueGeoReplicationStatus { + return []QueueGeoReplicationStatus{ + QueueGeoReplicationStatusLive, + QueueGeoReplicationStatusBootstrap, + QueueGeoReplicationStatusUnavailable, + } +} + +// StorageErrorCode - Error codes returned by the service +type StorageErrorCode string + +const ( + StorageErrorCodeAccountAlreadyExists StorageErrorCode = "AccountAlreadyExists" + StorageErrorCodeAccountBeingCreated StorageErrorCode = "AccountBeingCreated" + StorageErrorCodeAccountIsDisabled StorageErrorCode = "AccountIsDisabled" + StorageErrorCodeAuthenticationFailed StorageErrorCode = "AuthenticationFailed" + StorageErrorCodeAuthorizationFailure StorageErrorCode = "AuthorizationFailure" + StorageErrorCodeAuthorizationPermissionMismatch StorageErrorCode = "AuthorizationPermissionMismatch" + StorageErrorCodeAuthorizationProtocolMismatch StorageErrorCode = "AuthorizationProtocolMismatch" + StorageErrorCodeAuthorizationResourceTypeMismatch StorageErrorCode = "AuthorizationResourceTypeMismatch" + StorageErrorCodeAuthorizationServiceMismatch StorageErrorCode = "AuthorizationServiceMismatch" + StorageErrorCodeAuthorizationSourceIPMismatch StorageErrorCode = "AuthorizationSourceIPMismatch" + StorageErrorCodeConditionHeadersNotSupported StorageErrorCode = "ConditionHeadersNotSupported" + StorageErrorCodeConditionNotMet StorageErrorCode = "ConditionNotMet" + StorageErrorCodeEmptyMetadataKey StorageErrorCode = "EmptyMetadataKey" + StorageErrorCodeFeatureVersionMismatch StorageErrorCode = "FeatureVersionMismatch" + StorageErrorCodeInsufficientAccountPermissions StorageErrorCode = "InsufficientAccountPermissions" + StorageErrorCodeInternalError StorageErrorCode = "InternalError" + StorageErrorCodeInvalidAuthenticationInfo StorageErrorCode = "InvalidAuthenticationInfo" + StorageErrorCodeInvalidHTTPVerb StorageErrorCode = "InvalidHttpVerb" + StorageErrorCodeInvalidHeaderValue StorageErrorCode = "InvalidHeaderValue" + StorageErrorCodeInvalidInput StorageErrorCode = "InvalidInput" + StorageErrorCodeInvalidMD5 StorageErrorCode = "InvalidMd5" + StorageErrorCodeInvalidMarker StorageErrorCode = "InvalidMarker" + StorageErrorCodeInvalidMetadata StorageErrorCode = "InvalidMetadata" + StorageErrorCodeInvalidQueryParameterValue StorageErrorCode = "InvalidQueryParameterValue" + StorageErrorCodeInvalidRange StorageErrorCode = "InvalidRange" + StorageErrorCodeInvalidResourceName StorageErrorCode = "InvalidResourceName" + StorageErrorCodeInvalidURI StorageErrorCode = "InvalidUri" + StorageErrorCodeInvalidXMLDocument StorageErrorCode = "InvalidXmlDocument" + StorageErrorCodeInvalidXMLNodeValue StorageErrorCode = "InvalidXmlNodeValue" + StorageErrorCodeMD5Mismatch StorageErrorCode = "Md5Mismatch" + StorageErrorCodeMessageNotFound StorageErrorCode = "MessageNotFound" + StorageErrorCodeMessageTooLarge StorageErrorCode = "MessageTooLarge" + StorageErrorCodeMetadataTooLarge StorageErrorCode = "MetadataTooLarge" + StorageErrorCodeMissingContentLengthHeader StorageErrorCode = "MissingContentLengthHeader" + StorageErrorCodeMissingRequiredHeader StorageErrorCode = "MissingRequiredHeader" + StorageErrorCodeMissingRequiredQueryParameter StorageErrorCode = "MissingRequiredQueryParameter" + StorageErrorCodeMissingRequiredXMLNode StorageErrorCode = "MissingRequiredXmlNode" + StorageErrorCodeMultipleConditionHeadersNotSupported StorageErrorCode = "MultipleConditionHeadersNotSupported" + StorageErrorCodeOperationTimedOut StorageErrorCode = "OperationTimedOut" + StorageErrorCodeOutOfRangeInput StorageErrorCode = "OutOfRangeInput" + StorageErrorCodeOutOfRangeQueryParameterValue StorageErrorCode = "OutOfRangeQueryParameterValue" + StorageErrorCodePopReceiptMismatch StorageErrorCode = "PopReceiptMismatch" + StorageErrorCodeQueueAlreadyExists StorageErrorCode = "QueueAlreadyExists" + StorageErrorCodeQueueBeingDeleted StorageErrorCode = "QueueBeingDeleted" + StorageErrorCodeQueueDisabled StorageErrorCode = "QueueDisabled" + StorageErrorCodeQueueNotEmpty StorageErrorCode = "QueueNotEmpty" + StorageErrorCodeQueueNotFound StorageErrorCode = "QueueNotFound" + StorageErrorCodeRequestBodyTooLarge StorageErrorCode = "RequestBodyTooLarge" + StorageErrorCodeRequestURLFailedToParse StorageErrorCode = "RequestUrlFailedToParse" + StorageErrorCodeResourceAlreadyExists StorageErrorCode = "ResourceAlreadyExists" + StorageErrorCodeResourceNotFound StorageErrorCode = "ResourceNotFound" + StorageErrorCodeResourceTypeMismatch StorageErrorCode = "ResourceTypeMismatch" + StorageErrorCodeServerBusy StorageErrorCode = "ServerBusy" + StorageErrorCodeUnsupportedHTTPVerb StorageErrorCode = "UnsupportedHttpVerb" + StorageErrorCodeUnsupportedHeader StorageErrorCode = "UnsupportedHeader" + StorageErrorCodeUnsupportedQueryParameter StorageErrorCode = "UnsupportedQueryParameter" + StorageErrorCodeUnsupportedXMLNode StorageErrorCode = "UnsupportedXmlNode" +) + +// PossibleStorageErrorCodeValues returns the possible values for the StorageErrorCode const type. +func PossibleStorageErrorCodeValues() []StorageErrorCode { + return []StorageErrorCode{ + StorageErrorCodeAccountAlreadyExists, + StorageErrorCodeAccountBeingCreated, + StorageErrorCodeAccountIsDisabled, + StorageErrorCodeAuthenticationFailed, + StorageErrorCodeAuthorizationFailure, + StorageErrorCodeAuthorizationPermissionMismatch, + StorageErrorCodeAuthorizationProtocolMismatch, + StorageErrorCodeAuthorizationResourceTypeMismatch, + StorageErrorCodeAuthorizationServiceMismatch, + StorageErrorCodeAuthorizationSourceIPMismatch, + StorageErrorCodeConditionHeadersNotSupported, + StorageErrorCodeConditionNotMet, + StorageErrorCodeEmptyMetadataKey, + StorageErrorCodeFeatureVersionMismatch, + StorageErrorCodeInsufficientAccountPermissions, + StorageErrorCodeInternalError, + StorageErrorCodeInvalidAuthenticationInfo, + StorageErrorCodeInvalidHTTPVerb, + StorageErrorCodeInvalidHeaderValue, + StorageErrorCodeInvalidInput, + StorageErrorCodeInvalidMD5, + StorageErrorCodeInvalidMarker, + StorageErrorCodeInvalidMetadata, + StorageErrorCodeInvalidQueryParameterValue, + StorageErrorCodeInvalidRange, + StorageErrorCodeInvalidResourceName, + StorageErrorCodeInvalidURI, + StorageErrorCodeInvalidXMLDocument, + StorageErrorCodeInvalidXMLNodeValue, + StorageErrorCodeMD5Mismatch, + StorageErrorCodeMessageNotFound, + StorageErrorCodeMessageTooLarge, + StorageErrorCodeMetadataTooLarge, + StorageErrorCodeMissingContentLengthHeader, + StorageErrorCodeMissingRequiredHeader, + StorageErrorCodeMissingRequiredQueryParameter, + StorageErrorCodeMissingRequiredXMLNode, + StorageErrorCodeMultipleConditionHeadersNotSupported, + StorageErrorCodeOperationTimedOut, + StorageErrorCodeOutOfRangeInput, + StorageErrorCodeOutOfRangeQueryParameterValue, + StorageErrorCodePopReceiptMismatch, + StorageErrorCodeQueueAlreadyExists, + StorageErrorCodeQueueBeingDeleted, + StorageErrorCodeQueueDisabled, + StorageErrorCodeQueueNotEmpty, + StorageErrorCodeQueueNotFound, + StorageErrorCodeRequestBodyTooLarge, + StorageErrorCodeRequestURLFailedToParse, + StorageErrorCodeResourceAlreadyExists, + StorageErrorCodeResourceNotFound, + StorageErrorCodeResourceTypeMismatch, + StorageErrorCodeServerBusy, + StorageErrorCodeUnsupportedHTTPVerb, + StorageErrorCodeUnsupportedHeader, + StorageErrorCodeUnsupportedQueryParameter, + StorageErrorCodeUnsupportedXMLNode, + } +} diff --git a/sdk/storage/azqueue/generated/zz_messageid_client.go b/sdk/storage/azqueue/internal/generated/zz_messageid_client.go similarity index 100% rename from sdk/storage/azqueue/generated/zz_messageid_client.go rename to sdk/storage/azqueue/internal/generated/zz_messageid_client.go diff --git a/sdk/storage/azqueue/generated/zz_messages_client.go b/sdk/storage/azqueue/internal/generated/zz_messages_client.go similarity index 100% rename from sdk/storage/azqueue/generated/zz_messages_client.go rename to sdk/storage/azqueue/internal/generated/zz_messages_client.go diff --git a/sdk/storage/azqueue/generated/zz_models.go b/sdk/storage/azqueue/internal/generated/zz_models.go similarity index 81% rename from sdk/storage/azqueue/generated/zz_models.go rename to sdk/storage/azqueue/internal/generated/zz_models.go index a58cf599fe83..22a7a2135981 100644 --- a/sdk/storage/azqueue/generated/zz_models.go +++ b/sdk/storage/azqueue/internal/generated/zz_models.go @@ -35,13 +35,13 @@ type CorsRule struct { AllowedMethods *string `xml:"AllowedMethods"` // REQUIRED; The origin domains that are permitted to make a request against the storage service via CORS. The origin domain -// is the domain from which the request originates. Note that the origin must be an exact -// case-sensitive match with the origin that the user age sends to the service. You can also use the wildcard character '*' -// to allow all origin domains to make requests via CORS. + // is the domain from which the request originates. Note that the origin must be an exact + // case-sensitive match with the origin that the user age sends to the service. You can also use the wildcard character '*' + // to allow all origin domains to make requests via CORS. AllowedOrigins *string `xml:"AllowedOrigins"` // REQUIRED; The response headers that may be sent in the response to the CORS request and exposed by the browser to the request -// issuer + // issuer ExposedHeaders *string `xml:"ExposedHeaders"` // REQUIRED; The maximum amount time that a browser should cache the preflight OPTIONS request. @@ -66,7 +66,7 @@ type DequeuedMessageItem struct { MessageText *string `xml:"MessageText"` // REQUIRED; This value is required to delete the Message. If deletion fails using this popreceipt then the message has been -// dequeued by another client. + // dequeued by another client. PopReceipt *string `xml:"PopReceipt"` // REQUIRED; The time that the message will again become visible in the Queue. @@ -85,7 +85,7 @@ type EnqueuedMessage struct { MessageID *string `xml:"MessageId"` // REQUIRED; This value is required to delete the Message. If deletion fails using this popreceipt then the message has been -// dequeued by another client. + // dequeued by another client. PopReceipt *string `xml:"PopReceipt"` // REQUIRED; The time that the message will again become visible in the Queue. @@ -94,8 +94,8 @@ type EnqueuedMessage struct { type GeoReplication struct { // REQUIRED; A GMT date/time value, to the second. All primary writes preceding this value are guaranteed to be available -// for read operations at the secondary. Primary writes after this point in time may or may -// not be available for reads. + // for read operations at the secondary. Primary writes after this point in time may or may + // not be available for reads. LastSyncTime *time.Time `xml:"LastSyncTime"` // REQUIRED; The status of the secondary location @@ -114,9 +114,9 @@ type ListQueuesSegmentResponse struct { Prefix *string `xml:"Prefix"` // REQUIRED - ServiceEndpoint *string `xml:"ServiceEndpoint,attr"` - Marker *string `xml:"Marker"` - QueueItems []*QueueItem `xml:"Queues>Queue"` + ServiceEndpoint *string `xml:"ServiceEndpoint,attr"` + Marker *string `xml:"Marker"` + QueueItems []*QueueItem `xml:"Queues>Queue"` } // Logging - Azure Analytics Logging settings. @@ -140,7 +140,7 @@ type Logging struct { // MessageIDClientDeleteOptions contains the optional parameters for the MessageIDClient.Delete method. type MessageIDClientDeleteOptions struct { // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -149,7 +149,7 @@ type MessageIDClientDeleteOptions struct { // MessageIDClientUpdateOptions contains the optional parameters for the MessageIDClient.Update method. type MessageIDClientUpdateOptions struct { // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -158,7 +158,7 @@ type MessageIDClientUpdateOptions struct { // MessagesClientClearOptions contains the optional parameters for the MessagesClient.Clear method. type MessagesClientClearOptions struct { // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -167,49 +167,49 @@ type MessagesClientClearOptions struct { // MessagesClientDequeueOptions contains the optional parameters for the MessagesClient.Dequeue method. type MessagesClientDequeueOptions struct { // Optional. A nonzero integer value that specifies the number of messages to retrieve from the queue, up to a maximum of -// 32. If fewer are visible, the visible messages are returned. By default, a single -// message is retrieved from the queue with this operation. + // 32. If fewer are visible, the visible messages are returned. By default, a single + // message is retrieved from the queue with this operation. NumberOfMessages *int32 // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 // Optional. Specifies the new visibility timeout value, in seconds, relative to server time. The default value is 30 seconds. -// A specified value must be larger than or equal to 1 second, and cannot be -// larger than 7 days, or larger than 2 hours on REST protocol versions prior to version 2011-08-18. The visibility timeout -// of a message can be set to a value later than the expiry time. + // A specified value must be larger than or equal to 1 second, and cannot be + // larger than 7 days, or larger than 2 hours on REST protocol versions prior to version 2011-08-18. The visibility timeout + // of a message can be set to a value later than the expiry time. Visibilitytimeout *int32 } // MessagesClientEnqueueOptions contains the optional parameters for the MessagesClient.Enqueue method. type MessagesClientEnqueueOptions struct { // Optional. Specifies the time-to-live interval for the message, in seconds. Prior to version 2017-07-29, the maximum time-to-live -// allowed is 7 days. For version 2017-07-29 or later, the maximum -// time-to-live can be any positive number, as well as -1 indicating that the message does not expire. If this parameter is -// omitted, the default time-to-live is 7 days. + // allowed is 7 days. For version 2017-07-29 or later, the maximum + // time-to-live can be any positive number, as well as -1 indicating that the message does not expire. If this parameter is + // omitted, the default time-to-live is 7 days. MessageTimeToLive *int32 // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 // Optional. If specified, the request must be made using an x-ms-version of 2011-08-18 or later. If not specified, the default -// value is 0. Specifies the new visibility timeout value, in seconds, -// relative to server time. The new value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility -// timeout of a message cannot be set to a value later than the expiry time. -// visibilitytimeout should be set to a value smaller than the time-to-live value. + // value is 0. Specifies the new visibility timeout value, in seconds, + // relative to server time. The new value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility + // timeout of a message cannot be set to a value later than the expiry time. + // visibilitytimeout should be set to a value smaller than the time-to-live value. Visibilitytimeout *int32 } // MessagesClientPeekOptions contains the optional parameters for the MessagesClient.Peek method. type MessagesClientPeekOptions struct { // Optional. A nonzero integer value that specifies the number of messages to retrieve from the queue, up to a maximum of -// 32. If fewer are visible, the visible messages are returned. By default, a single -// message is retrieved from the queue with this operation. + // 32. If fewer are visible, the visible messages are returned. By default, a single + // message is retrieved from the queue with this operation. NumberOfMessages *int32 // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -251,12 +251,12 @@ type PeekedMessageItem struct { // QueueClientCreateOptions contains the optional parameters for the QueueClient.Create method. type QueueClientCreateOptions struct { // Optional. Include this parameter to specify that the queue's metadata be returned as part of the response body. Note that -// metadata requested with this parameter must be stored in accordance with the -// naming restrictions imposed by the 2009-09-19 version of the Queue service. Beginning with this version, all metadata names -// must adhere to the naming conventions for C# identifiers. + // metadata requested with this parameter must be stored in accordance with the + // naming restrictions imposed by the 2009-09-19 version of the Queue service. Beginning with this version, all metadata names + // must adhere to the naming conventions for C# identifiers. Metadata map[string]string // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -265,7 +265,7 @@ type QueueClientCreateOptions struct { // QueueClientDeleteOptions contains the optional parameters for the QueueClient.Delete method. type QueueClientDeleteOptions struct { // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -274,7 +274,7 @@ type QueueClientDeleteOptions struct { // QueueClientGetAccessPolicyOptions contains the optional parameters for the QueueClient.GetAccessPolicy method. type QueueClientGetAccessPolicyOptions struct { // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -283,7 +283,7 @@ type QueueClientGetAccessPolicyOptions struct { // QueueClientGetPropertiesOptions contains the optional parameters for the QueueClient.GetProperties method. type QueueClientGetPropertiesOptions struct { // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -292,7 +292,7 @@ type QueueClientGetPropertiesOptions struct { // QueueClientSetAccessPolicyOptions contains the optional parameters for the QueueClient.SetAccessPolicy method. type QueueClientSetAccessPolicyOptions struct { // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -301,12 +301,12 @@ type QueueClientSetAccessPolicyOptions struct { // QueueClientSetMetadataOptions contains the optional parameters for the QueueClient.SetMetadata method. type QueueClientSetMetadataOptions struct { // Optional. Include this parameter to specify that the queue's metadata be returned as part of the response body. Note that -// metadata requested with this parameter must be stored in accordance with the -// naming restrictions imposed by the 2009-09-19 version of the Queue service. Beginning with this version, all metadata names -// must adhere to the naming conventions for C# identifiers. + // metadata requested with this parameter must be stored in accordance with the + // naming restrictions imposed by the 2009-09-19 version of the Queue service. Beginning with this version, all metadata names + // must adhere to the naming conventions for C# identifiers. Metadata map[string]string // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -333,14 +333,14 @@ type RetentionPolicy struct { Enabled *bool `xml:"Enabled"` // Indicates the number of days that metrics or logging or soft-deleted data should be retained. All data older than this -// value will be deleted + // value will be deleted Days *int32 `xml:"Days"` } // ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. type ServiceClientGetPropertiesOptions struct { // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -349,7 +349,7 @@ type ServiceClientGetPropertiesOptions struct { // ServiceClientGetStatisticsOptions contains the optional parameters for the ServiceClient.GetStatistics method. type ServiceClientGetStatisticsOptions struct { // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -360,21 +360,21 @@ type ServiceClientListQueuesSegmentOptions struct { // Include this parameter to specify that the queues' metadata be returned as part of the response body. Include []string // A string value that identifies the portion of the list of queues to be returned with the next listing operation. The operation -// returns the NextMarker value within the response body if the listing -// operation did not return all queues remaining to be listed with the current page. The NextMarker value can be used as the -// value for the marker parameter in a subsequent call to request the next page -// of list items. The marker value is opaque to the client. + // returns the NextMarker value within the response body if the listing + // operation did not return all queues remaining to be listed with the current page. The NextMarker value can be used as the + // value for the marker parameter in a subsequent call to request the next page + // of list items. The marker value is opaque to the client. Marker *string // Specifies the maximum number of queues to return. If the request does not specify maxresults, or specifies a value greater -// than 5000, the server will return up to 5000 items. Note that if the listing -// operation crosses a partition boundary, then the service will return a continuation token for retrieving the remainder -// of the results. For this reason, it is possible that the service will return -// fewer results than specified by maxresults, or than the default of 5000. + // than 5000, the server will return up to 5000 items. Note that if the listing + // operation crosses a partition boundary, then the service will return a continuation token for retrieving the remainder + // of the results. For this reason, it is possible that the service will return + // fewer results than specified by maxresults, or than the default of 5000. Maxresults *int32 // Filters the results to return only queues whose name begins with the specified prefix. Prefix *string // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -383,7 +383,7 @@ type ServiceClientListQueuesSegmentOptions struct { // ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. type ServiceClientSetPropertiesOptions struct { // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage -// analytics logging is enabled. + // analytics logging is enabled. RequestID *string // The The timeout parameter is expressed in seconds. For more information, see Timeout *int32 @@ -422,4 +422,3 @@ type StorageServiceStats struct { // Geo-Replication information for the Secondary Storage Service GeoReplication *GeoReplication `xml:"GeoReplication"` } - diff --git a/sdk/storage/azqueue/generated/zz_models_serde.go b/sdk/storage/azqueue/internal/generated/zz_models_serde.go similarity index 86% rename from sdk/storage/azqueue/generated/zz_models_serde.go rename to sdk/storage/azqueue/internal/generated/zz_models_serde.go index e34236f6e5b3..30fda8b47976 100644 --- a/sdk/storage/azqueue/generated/zz_models_serde.go +++ b/sdk/storage/azqueue/internal/generated/zz_models_serde.go @@ -24,11 +24,11 @@ func (a AccessPolicy) MarshalXML(e *xml.Encoder, start xml.StartElement) error { aux := &struct { *alias Expiry *timeRFC3339 `xml:"Expiry"` - Start *timeRFC3339 `xml:"Start"` + Start *timeRFC3339 `xml:"Start"` }{ - alias: (*alias)(&a), + alias: (*alias)(&a), Expiry: (*timeRFC3339)(a.Expiry), - Start: (*timeRFC3339)(a.Start), + Start: (*timeRFC3339)(a.Start), } return e.EncodeElement(aux, start) } @@ -39,7 +39,7 @@ func (a *AccessPolicy) UnmarshalXML(d *xml.Decoder, start xml.StartElement) erro aux := &struct { *alias Expiry *timeRFC3339 `xml:"Expiry"` - Start *timeRFC3339 `xml:"Start"` + Start *timeRFC3339 `xml:"Start"` }{ alias: (*alias)(a), } @@ -56,13 +56,13 @@ func (d DequeuedMessageItem) MarshalXML(e *xml.Encoder, start xml.StartElement) type alias DequeuedMessageItem aux := &struct { *alias - ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` - InsertionTime *timeRFC1123 `xml:"InsertionTime"` + ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` + InsertionTime *timeRFC1123 `xml:"InsertionTime"` TimeNextVisible *timeRFC1123 `xml:"TimeNextVisible"` }{ - alias: (*alias)(&d), - ExpirationTime: (*timeRFC1123)(d.ExpirationTime), - InsertionTime: (*timeRFC1123)(d.InsertionTime), + alias: (*alias)(&d), + ExpirationTime: (*timeRFC1123)(d.ExpirationTime), + InsertionTime: (*timeRFC1123)(d.InsertionTime), TimeNextVisible: (*timeRFC1123)(d.TimeNextVisible), } return e.EncodeElement(aux, start) @@ -73,8 +73,8 @@ func (d *DequeuedMessageItem) UnmarshalXML(d *xml.Decoder, start xml.StartElemen type alias DequeuedMessageItem aux := &struct { *alias - ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` - InsertionTime *timeRFC1123 `xml:"InsertionTime"` + ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` + InsertionTime *timeRFC1123 `xml:"InsertionTime"` TimeNextVisible *timeRFC1123 `xml:"TimeNextVisible"` }{ alias: (*alias)(d), @@ -93,13 +93,13 @@ func (e EnqueuedMessage) MarshalXML(e *xml.Encoder, start xml.StartElement) erro type alias EnqueuedMessage aux := &struct { *alias - ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` - InsertionTime *timeRFC1123 `xml:"InsertionTime"` + ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` + InsertionTime *timeRFC1123 `xml:"InsertionTime"` TimeNextVisible *timeRFC1123 `xml:"TimeNextVisible"` }{ - alias: (*alias)(&e), - ExpirationTime: (*timeRFC1123)(e.ExpirationTime), - InsertionTime: (*timeRFC1123)(e.InsertionTime), + alias: (*alias)(&e), + ExpirationTime: (*timeRFC1123)(e.ExpirationTime), + InsertionTime: (*timeRFC1123)(e.InsertionTime), TimeNextVisible: (*timeRFC1123)(e.TimeNextVisible), } return e.EncodeElement(aux, start) @@ -110,8 +110,8 @@ func (e *EnqueuedMessage) UnmarshalXML(d *xml.Decoder, start xml.StartElement) e type alias EnqueuedMessage aux := &struct { *alias - ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` - InsertionTime *timeRFC1123 `xml:"InsertionTime"` + ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` + InsertionTime *timeRFC1123 `xml:"InsertionTime"` TimeNextVisible *timeRFC1123 `xml:"TimeNextVisible"` }{ alias: (*alias)(e), @@ -132,7 +132,7 @@ func (g GeoReplication) MarshalXML(e *xml.Encoder, start xml.StartElement) error *alias LastSyncTime *timeRFC1123 `xml:"LastSyncTime"` }{ - alias: (*alias)(&g), + alias: (*alias)(&g), LastSyncTime: (*timeRFC1123)(g.LastSyncTime), } return e.EncodeElement(aux, start) @@ -175,11 +175,11 @@ func (p PeekedMessageItem) MarshalXML(e *xml.Encoder, start xml.StartElement) er aux := &struct { *alias ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` - InsertionTime *timeRFC1123 `xml:"InsertionTime"` + InsertionTime *timeRFC1123 `xml:"InsertionTime"` }{ - alias: (*alias)(&p), + alias: (*alias)(&p), ExpirationTime: (*timeRFC1123)(p.ExpirationTime), - InsertionTime: (*timeRFC1123)(p.InsertionTime), + InsertionTime: (*timeRFC1123)(p.InsertionTime), } return e.EncodeElement(aux, start) } @@ -190,7 +190,7 @@ func (p *PeekedMessageItem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) aux := &struct { *alias ExpirationTime *timeRFC1123 `xml:"ExpirationTime"` - InsertionTime *timeRFC1123 `xml:"InsertionTime"` + InsertionTime *timeRFC1123 `xml:"InsertionTime"` }{ alias: (*alias)(p), } @@ -235,8 +235,8 @@ func (s *StorageError) UnmarshalJSON(data []byte) error { var err error switch key { case "Message": - err = unpopulate(val, "Message", &s.Message) - delete(rawMsg, key) + err = unpopulate(val, "Message", &s.Message) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -279,4 +279,3 @@ func unpopulate(data json.RawMessage, fn string, v interface{}) error { } return nil } - diff --git a/sdk/storage/azqueue/generated/zz_queue_client.go b/sdk/storage/azqueue/internal/generated/zz_queue_client.go similarity index 99% rename from sdk/storage/azqueue/generated/zz_queue_client.go rename to sdk/storage/azqueue/internal/generated/zz_queue_client.go index 1b14000267ef..de898f3b3ef3 100644 --- a/sdk/storage/azqueue/generated/zz_queue_client.go +++ b/sdk/storage/azqueue/internal/generated/zz_queue_client.go @@ -24,7 +24,7 @@ import ( // Don't use this type directly, use NewQueueClient() instead. type QueueClient struct { endpoint string - pl runtime.Pipeline + pl runtime.Pipeline } // NewQueueClient creates a new instance of QueueClient with the specified values. @@ -33,7 +33,7 @@ type QueueClient struct { func NewQueueClient(endpoint string, pl runtime.Pipeline) *QueueClient { client := &QueueClient{ endpoint: endpoint, - pl: pl, + pl: pl, } return client } @@ -332,7 +332,7 @@ func (client *QueueClient) setAccessPolicyCreateRequest(ctx context.Context, que } req.Raw().Header["Accept"] = []string{"application/xml"} type wrapper struct { - XMLName xml.Name `xml:"SignedIdentifiers"` + XMLName xml.Name `xml:"SignedIdentifiers"` QueueACL *[]*SignedIdentifier `xml:"SignedIdentifier"` } return req, runtime.MarshalAsXML(req, wrapper{QueueACL: &queueACL}) @@ -419,4 +419,3 @@ func (client *QueueClient) setMetadataHandleResponse(resp *http.Response) (Queue } return result, nil } - diff --git a/sdk/storage/azqueue/generated/zz_response_types.go b/sdk/storage/azqueue/internal/generated/zz_response_types.go similarity index 100% rename from sdk/storage/azqueue/generated/zz_response_types.go rename to sdk/storage/azqueue/internal/generated/zz_response_types.go diff --git a/sdk/storage/azqueue/generated/zz_service_client.go b/sdk/storage/azqueue/internal/generated/zz_service_client.go similarity index 100% rename from sdk/storage/azqueue/generated/zz_service_client.go rename to sdk/storage/azqueue/internal/generated/zz_service_client.go diff --git a/sdk/storage/azqueue/generated/zz_time_rfc1123.go b/sdk/storage/azqueue/internal/generated/zz_time_rfc1123.go similarity index 100% rename from sdk/storage/azqueue/generated/zz_time_rfc1123.go rename to sdk/storage/azqueue/internal/generated/zz_time_rfc1123.go diff --git a/sdk/storage/azqueue/generated/zz_time_rfc3339.go b/sdk/storage/azqueue/internal/generated/zz_time_rfc3339.go similarity index 100% rename from sdk/storage/azqueue/generated/zz_time_rfc3339.go rename to sdk/storage/azqueue/internal/generated/zz_time_rfc3339.go diff --git a/sdk/storage/azqueue/generated/zz_xml_helper.go b/sdk/storage/azqueue/internal/generated/zz_xml_helper.go similarity index 100% rename from sdk/storage/azqueue/generated/zz_xml_helper.go rename to sdk/storage/azqueue/internal/generated/zz_xml_helper.go diff --git a/sdk/storage/azqueue/internal/shared/shared.go b/sdk/storage/azqueue/internal/shared/shared.go new file mode 100644 index 000000000000..0ff52039d30e --- /dev/null +++ b/sdk/storage/azqueue/internal/shared/shared.go @@ -0,0 +1,146 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package shared + +import ( + "errors" + "fmt" + "hash/crc64" + "net" + "strings" +) + +const ( + TokenScope = "https://storage.azure.com/.default" +) + +const ( + HeaderAuthorization = "Authorization" + HeaderXmsDate = "x-ms-date" + HeaderContentLength = "Content-Length" + HeaderContentEncoding = "Content-Encoding" + HeaderContentLanguage = "Content-Language" + HeaderContentType = "Content-Type" + HeaderContentMD5 = "Content-MD5" + HeaderIfModifiedSince = "If-Modified-Since" + HeaderIfMatch = "If-Match" + HeaderIfNoneMatch = "If-None-Match" + HeaderIfUnmodifiedSince = "If-Unmodified-Since" + HeaderRange = "Range" +) + +const crc64Polynomial uint64 = 0x9A6C9329AC4BC9B5 + +var CRC64Table = crc64.MakeTable(crc64Polynomial) + +// CopyOptions returns a zero-value T if opts is nil. +// If opts is not nil, a copy is made and its address returned. +func CopyOptions[T any](opts *T) *T { + if opts == nil { + return new(T) + } + cp := *opts + return &cp +} + +var errConnectionString = errors.New("connection string is either blank or malformed. The expected connection string " + + "should contain key value pairs separated by semicolons. For example 'DefaultEndpointsProtocol=https;AccountName=;" + + "AccountKey=;EndpointSuffix=core.windows.net'") + +type ParsedConnectionString struct { + ServiceURL string + AccountName string + AccountKey string +} + +func ParseConnectionString(connectionString string) (ParsedConnectionString, error) { + const ( + defaultScheme = "https" + defaultSuffix = "core.windows.net" + ) + + connStrMap := make(map[string]string) + connectionString = strings.TrimRight(connectionString, ";") + + splitString := strings.Split(connectionString, ";") + if len(splitString) == 0 { + return ParsedConnectionString{}, errConnectionString + } + for _, stringPart := range splitString { + parts := strings.SplitN(stringPart, "=", 2) + if len(parts) != 2 { + return ParsedConnectionString{}, errConnectionString + } + connStrMap[parts[0]] = parts[1] + } + + accountName, ok := connStrMap["AccountName"] + if !ok { + return ParsedConnectionString{}, errors.New("connection string missing AccountName") + } + + accountKey, ok := connStrMap["AccountKey"] + if !ok { + sharedAccessSignature, ok := connStrMap["SharedAccessSignature"] + if !ok { + return ParsedConnectionString{}, errors.New("connection string missing AccountKey and SharedAccessSignature") + } + return ParsedConnectionString{ + ServiceURL: fmt.Sprintf("%v://%v.blob.%v/?%v", defaultScheme, accountName, defaultSuffix, sharedAccessSignature), + }, nil + } + + protocol, ok := connStrMap["DefaultEndpointsProtocol"] + if !ok { + protocol = defaultScheme + } + + suffix, ok := connStrMap["EndpointSuffix"] + if !ok { + suffix = defaultSuffix + } + + if blobEndpoint, ok := connStrMap["BlobEndpoint"]; ok { + return ParsedConnectionString{ + ServiceURL: blobEndpoint, + AccountName: accountName, + AccountKey: accountKey, + }, nil + } + + return ParsedConnectionString{ + ServiceURL: fmt.Sprintf("%v://%v.blob.%v", protocol, accountName, suffix), + AccountName: accountName, + AccountKey: accountKey, + }, nil +} + +func GetClientOptions[T any](o *T) *T { + if o == nil { + return new(T) + } + return o +} + +// IsIPEndpointStyle checkes if URL's host is IP, in this case the storage account endpoint will be composed as: +// http(s)://IP(:port)/storageaccount/container/... +// As url's Host property, host could be both host or host:port +func IsIPEndpointStyle(host string) bool { + if host == "" { + return false + } + if h, _, err := net.SplitHostPort(host); err == nil { + host = h + } + // For IPv6, there could be case where SplitHostPort fails for cannot finding port. + // In this case, eliminate the '[' and ']' in the URL. + // For details about IPv6 URL, please refer to https://tools.ietf.org/html/rfc2732 + if host[0] == '[' && host[len(host)-1] == ']' { + host = host[1 : len(host)-1] + } + return net.ParseIP(host) != nil +} From 275b4575ffac8484ad5311b216e10c6cf7c248ae Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Wed, 28 Dec 2022 15:19:04 -0800 Subject: [PATCH 06/17] added basic models --- sdk/storage/azqueue/internal/base/clients.go | 15 +-- .../azqueue/internal/exported/version.go | 12 ++ .../internal/generated/service_client.go | 17 +++ sdk/storage/azqueue/internal/shared/shared.go | 10 +- sdk/storage/azqueue/service/client.go | 75 +++++++++++ sdk/storage/azqueue/service/models.go | 119 ++++++++++++++++++ 6 files changed, 232 insertions(+), 16 deletions(-) create mode 100644 sdk/storage/azqueue/internal/exported/version.go create mode 100644 sdk/storage/azqueue/internal/generated/service_client.go create mode 100644 sdk/storage/azqueue/service/client.go create mode 100644 sdk/storage/azqueue/service/models.go diff --git a/sdk/storage/azqueue/internal/base/clients.go b/sdk/storage/azqueue/internal/base/clients.go index 27baa58d216a..b270c96f6448 100644 --- a/sdk/storage/azqueue/internal/base/clients.go +++ b/sdk/storage/azqueue/internal/base/clients.go @@ -29,23 +29,16 @@ func NewClient[T any](inner *T) *Client[T] { return &Client[T]{inner: inner} } -func NewServiceClient(containerURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.ServiceClient] { +func NewServiceClient(queueURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.ServiceClient] { return &Client[generated.ServiceClient]{ - inner: generated.NewServiceClient(containerURL, pipeline), + inner: generated.NewServiceClient(queueURL, pipeline), sharedKey: sharedKey, } } -func NewQueueClient(containerURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.QueueClient] { +func NewQueueClient(queueURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.QueueClient] { return &Client[generated.QueueClient]{ - inner: generated.NewQueueClient(containerURL, pipeline), - sharedKey: sharedKey, - } -} - -func NewMessagesClient(blobURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *Client[generated.MessagesClient] { - return &Client[generated.MessagesClient]{ - inner: generated.NewMessagesClient(blobURL, pipeline), + inner: generated.NewQueueClient(queueURL, pipeline), sharedKey: sharedKey, } } diff --git a/sdk/storage/azqueue/internal/exported/version.go b/sdk/storage/azqueue/internal/exported/version.go new file mode 100644 index 000000000000..cfbc93f4ea9d --- /dev/null +++ b/sdk/storage/azqueue/internal/exported/version.go @@ -0,0 +1,12 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package exported + +const ( + ModuleName = "azqueue" + ModuleVersion = "v0.1.0" +) diff --git a/sdk/storage/azqueue/internal/generated/service_client.go b/sdk/storage/azqueue/internal/generated/service_client.go new file mode 100644 index 000000000000..1f449b955e82 --- /dev/null +++ b/sdk/storage/azqueue/internal/generated/service_client.go @@ -0,0 +1,17 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package generated + +import "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + +func (client *ServiceClient) Endpoint() string { + return client.endpoint +} + +func (client *ServiceClient) Pipeline() runtime.Pipeline { + return client.pl +} diff --git a/sdk/storage/azqueue/internal/shared/shared.go b/sdk/storage/azqueue/internal/shared/shared.go index 0ff52039d30e..e634fec6fbc6 100644 --- a/sdk/storage/azqueue/internal/shared/shared.go +++ b/sdk/storage/azqueue/internal/shared/shared.go @@ -90,7 +90,7 @@ func ParseConnectionString(connectionString string) (ParsedConnectionString, err return ParsedConnectionString{}, errors.New("connection string missing AccountKey and SharedAccessSignature") } return ParsedConnectionString{ - ServiceURL: fmt.Sprintf("%v://%v.blob.%v/?%v", defaultScheme, accountName, defaultSuffix, sharedAccessSignature), + ServiceURL: fmt.Sprintf("%v://%v.queue.%v/?%v", defaultScheme, accountName, defaultSuffix, sharedAccessSignature), }, nil } @@ -104,16 +104,16 @@ func ParseConnectionString(connectionString string) (ParsedConnectionString, err suffix = defaultSuffix } - if blobEndpoint, ok := connStrMap["BlobEndpoint"]; ok { + if queueEndpoint, ok := connStrMap["QueueEndpoint"]; ok { return ParsedConnectionString{ - ServiceURL: blobEndpoint, + ServiceURL: queueEndpoint, AccountName: accountName, AccountKey: accountKey, }, nil } return ParsedConnectionString{ - ServiceURL: fmt.Sprintf("%v://%v.blob.%v", protocol, accountName, suffix), + ServiceURL: fmt.Sprintf("%v://%v.queue.%v", protocol, accountName, suffix), AccountName: accountName, AccountKey: accountKey, }, nil @@ -127,7 +127,7 @@ func GetClientOptions[T any](o *T) *T { } // IsIPEndpointStyle checkes if URL's host is IP, in this case the storage account endpoint will be composed as: -// http(s)://IP(:port)/storageaccount/container/... +// http(s)://IP(:port)/storageaccount/queue/... // As url's Host property, host could be both host or host:port func IsIPEndpointStyle(host string) bool { if host == "" { diff --git a/sdk/storage/azqueue/service/client.go b/sdk/storage/azqueue/service/client.go new file mode 100644 index 000000000000..b29e4a709982 --- /dev/null +++ b/sdk/storage/azqueue/service/client.go @@ -0,0 +1,75 @@ +package service + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/base" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/exported" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/generated" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/shared" +) + +// ClientOptions contains the optional parameters when creating a Client. +type ClientOptions struct { + azcore.ClientOptions +} + +// Client represents a URL to the Azure Queue Storage service allowing you to manipulate queues. +type Client base.Client[generated.ServiceClient] + +// NewClientWithNoCredential creates an instance of Client with the specified values. +// This is used to anonymously access a storage account or with a shared access signature (SAS) token. +// - serviceURL - the URL of the storage account e.g. https://.queue.core.windows.net/? +// - options - client options; pass nil to accept the default values +func NewClientWithNoCredential(serviceURL string, options *ClientOptions) (*Client, error) { + conOptions := shared.GetClientOptions(options) + pl := runtime.NewPipeline(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + + return (*Client)(base.NewServiceClient(serviceURL, pl, nil)), nil +} + +// NewClientWithSharedKeyCredential creates an instance of Client with the specified values. +// - serviceURL - the URL of the storage account e.g. https://.queue.core.windows.net/ +// - cred - a SharedKeyCredential created with the matching storage account and access key +// - options - client options; pass nil to accept the default values +func NewClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredential, options *ClientOptions) (*Client, error) { + authPolicy := exported.NewSharedKeyCredPolicy(cred) + conOptions := shared.GetClientOptions(options) + conOptions.PerRetryPolicies = append(conOptions.PerRetryPolicies, authPolicy) + pl := runtime.NewPipeline(exported.ModuleName, exported.ModuleVersion, runtime.PipelineOptions{}, &conOptions.ClientOptions) + + return (*Client)(base.NewServiceClient(serviceURL, pl, cred)), nil +} + +// NewClientFromConnectionString creates an instance of Client with the specified values. +// - connectionString - a connection string for the desired storage account +// - options - client options; pass nil to accept the default values +func NewClientFromConnectionString(connectionString string, options *ClientOptions) (*Client, error) { + parsed, err := shared.ParseConnectionString(connectionString) + if err != nil { + return nil, err + } + + if parsed.AccountKey != "" && parsed.AccountName != "" { + credential, err := exported.NewSharedKeyCredential(parsed.AccountName, parsed.AccountKey) + if err != nil { + return nil, err + } + return NewClientWithSharedKeyCredential(parsed.ServiceURL, credential, options) + } + + return NewClientWithNoCredential(parsed.ServiceURL, options) +} + +func (s *Client) generated() *generated.ServiceClient { + return base.InnerClient((*base.Client[generated.ServiceClient])(s)) +} + +func (s *Client) sharedKey() *SharedKeyCredential { + return base.SharedKey((*base.Client[generated.ServiceClient])(s)) +} + +// URL returns the URL endpoint used by the Client object. +func (s *Client) URL() string { + return s.generated().Endpoint() +} diff --git a/sdk/storage/azqueue/service/models.go b/sdk/storage/azqueue/service/models.go new file mode 100644 index 000000000000..02dc858a972e --- /dev/null +++ b/sdk/storage/azqueue/service/models.go @@ -0,0 +1,119 @@ +package service + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/exported" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/generated" +) + +// SharedKeyCredential contains an account's name and its primary or secondary key. +type SharedKeyCredential = exported.SharedKeyCredential + +// NewSharedKeyCredential creates an immutable SharedKeyCredential containing the +// storage account's name and either its primary or secondary key. +func NewSharedKeyCredential(accountName, accountKey string) (*SharedKeyCredential, error) { + return exported.NewSharedKeyCredential(accountName, accountKey) +} + +// CorsRule - CORS is an HTTP feature that enables a web application running under one domain to access resources in another +// domain. Web browsers implement a security restriction known as same-origin policy that +// prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin +// domain) to call APIs in another domain +type CorsRule = generated.CorsRule + +// GeoReplication - Geo-Replication information for the Secondary Storage Service +type GeoReplication = generated.GeoReplication + +// RetentionPolicy - the retention policy which determines how long the associated data should persist +type RetentionPolicy = generated.RetentionPolicy + +// Metrics - a summary of request statistics grouped by API in hour or minute aggregates for queues +type Metrics = generated.Metrics + +// Logging - Azure Analytics Logging settings. +type Logging = generated.Logging + +// StorageServiceProperties - Storage Service Properties. +type StorageServiceProperties = generated.StorageServiceProperties + +// StorageServiceStats - Stats for the storage service. +type StorageServiceStats = generated.StorageServiceStats + +// --------------------------------------------------------------------------------------------------------------------- + +// ListQueuesOptions provides set of configurations for ListQueues operation +type ListQueuesOptions struct { + Include ListQueuesInclude + + // A string value that identifies the portion of the list of queues to be returned with the next listing operation. The + // operation returns the NextMarker value within the response body if the listing operation did not return all queues + // remaining to be listed with the current page. The NextMarker value can be used as the value for the marker parameter in + // a subsequent call to request the next page of list items. The marker value is opaque to the client. + Marker *string + + // Specifies the maximum number of queues to return. If the request does not specify max results, or specifies a value + // greater than 5000, the server will return up to 5000 items. Note that if the listing operation crosses a partition boundary, + // then the service will return a continuation token for retrieving the remainder of the results. For this reason, it is possible + // that the service will return fewer results than specified by max results, or than the default of 5000. + MaxResults *int32 + + // Filters the results to return only queues whose name begins with the specified prefix. + Prefix *string +} + +// ListQueuesInclude indicates what additional information the service should return with each queue. +type ListQueuesInclude struct { + // Tells the service whether to return metadata for each queue. + Metadata bool +} + +// --------------------------------------------------------------------------------------------------------------------- + +// SetPropertiesOptions provides set of options for Client.SetProperties +type SetPropertiesOptions struct { + // The set of CORS rules. + Cors []*CorsRule + + // a summary of request statistics grouped by API in hour or minute aggregates for queues + HourMetrics *Metrics + + // Azure Analytics Logging settings. + Logging *Logging + + // a summary of request statistics grouped by API in hour or minute aggregates for queues + MinuteMetrics *Metrics +} + +func (o *SetPropertiesOptions) format() (generated.StorageServiceProperties, *generated.ServiceClientSetPropertiesOptions) { + if o == nil { + return generated.StorageServiceProperties{}, nil + } + + return generated.StorageServiceProperties{ + Cors: o.Cors, + HourMetrics: o.HourMetrics, + Logging: o.Logging, + MinuteMetrics: o.MinuteMetrics, + }, nil +} + +// --------------------------------------------------------------------------------------------------------------------- + +// GetPropertiesOptions contains the optional parameters for the Client.GetProperties method. +type GetPropertiesOptions struct { + // placeholder for future options +} + +func (o *GetPropertiesOptions) format() *generated.ServiceClientGetPropertiesOptions { + return nil +} + +// --------------------------------------------------------------------------------------------------------------------- + +// GetStatisticsOptions provides set of options for Client.GetStatistics +type GetStatisticsOptions struct { + // placeholder for future options +} + +func (o *GetStatisticsOptions) format() *generated.ServiceClientGetStatisticsOptions { + return nil +} From 045419e8539567e84c2c12558aa700c8885ce242 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Thu, 29 Dec 2022 14:55:06 -0800 Subject: [PATCH 07/17] regenrated and added pager --- .../azqueue/internal/generated/autorest.md | 14 +++++ .../internal/generated/zz_models_serde.go | 52 +++++++++---------- sdk/storage/azqueue/service/responses.go | 1 + 3 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 sdk/storage/azqueue/service/responses.go diff --git a/sdk/storage/azqueue/internal/generated/autorest.md b/sdk/storage/azqueue/internal/generated/autorest.md index e75176d443e5..cff0ad9a3aad 100644 --- a/sdk/storage/azqueue/internal/generated/autorest.md +++ b/sdk/storage/azqueue/internal/generated/autorest.md @@ -67,4 +67,18 @@ directive: replace(/func \(client \*ServiceClient\) NewListQueuesSegmentPager\(.+\/\/ listQueuesSegmentCreateRequest creates the ListQueuesSegment request/s, `// ListQueuesSegmentCreateRequest creates the ListQueuesFlatSegment ListQueuesSegment`). replace(/\(client \*ServiceClient\) listQueuesSegmentCreateRequest\(/, `(client *ServiceClient) ListQueuesSegmentCreateRequest(`). replace(/\(client \*ServiceClient\) listQueuesSegmentHandleResponse\(/, `(client *ServiceClient) ListQueuesSegmentHandleResponse(`); +``` + +### Fix function marshal and unmarshal signatures to be non-conflicting + +``` yaml +directive: + - from: zz_models_serde.go + where: $ + transform: >- + return $. + replace(/d\s*\*xml\.Decoder/g, "dec *xml.Decoder"). + replace(/d\.DecodeElement\(/g, "dec.DecodeElement("). + replace(/e\s*\*xml\.Encoder/g, "enc *xml.Encoder"). + replace(/e\.EncodeElement\(/g, "enc.EncodeElement("); ``` \ No newline at end of file diff --git a/sdk/storage/azqueue/internal/generated/zz_models_serde.go b/sdk/storage/azqueue/internal/generated/zz_models_serde.go index e34236f6e5b3..665a367f6156 100644 --- a/sdk/storage/azqueue/internal/generated/zz_models_serde.go +++ b/sdk/storage/azqueue/internal/generated/zz_models_serde.go @@ -19,7 +19,7 @@ import ( ) // MarshalXML implements the xml.Marshaller interface for type AccessPolicy. -func (a AccessPolicy) MarshalXML(e *xml.Encoder, start xml.StartElement) error { +func (a AccessPolicy) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { type alias AccessPolicy aux := &struct { *alias @@ -30,11 +30,11 @@ func (a AccessPolicy) MarshalXML(e *xml.Encoder, start xml.StartElement) error { Expiry: (*timeRFC3339)(a.Expiry), Start: (*timeRFC3339)(a.Start), } - return e.EncodeElement(aux, start) + return enc.EncodeElement(aux, start) } // UnmarshalXML implements the xml.Unmarshaller interface for type AccessPolicy. -func (a *AccessPolicy) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { +func (a *AccessPolicy) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { type alias AccessPolicy aux := &struct { *alias @@ -43,7 +43,7 @@ func (a *AccessPolicy) UnmarshalXML(d *xml.Decoder, start xml.StartElement) erro }{ alias: (*alias)(a), } - if err := d.DecodeElement(aux, &start); err != nil { + if err := dec.DecodeElement(aux, &start); err != nil { return err } a.Expiry = (*time.Time)(aux.Expiry) @@ -52,7 +52,7 @@ func (a *AccessPolicy) UnmarshalXML(d *xml.Decoder, start xml.StartElement) erro } // MarshalXML implements the xml.Marshaller interface for type DequeuedMessageItem. -func (d DequeuedMessageItem) MarshalXML(e *xml.Encoder, start xml.StartElement) error { +func (d DequeuedMessageItem) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { type alias DequeuedMessageItem aux := &struct { *alias @@ -65,11 +65,11 @@ func (d DequeuedMessageItem) MarshalXML(e *xml.Encoder, start xml.StartElement) InsertionTime: (*timeRFC1123)(d.InsertionTime), TimeNextVisible: (*timeRFC1123)(d.TimeNextVisible), } - return e.EncodeElement(aux, start) + return enc.EncodeElement(aux, start) } // UnmarshalXML implements the xml.Unmarshaller interface for type DequeuedMessageItem. -func (d *DequeuedMessageItem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { +func (d *DequeuedMessageItem) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { type alias DequeuedMessageItem aux := &struct { *alias @@ -79,7 +79,7 @@ func (d *DequeuedMessageItem) UnmarshalXML(d *xml.Decoder, start xml.StartElemen }{ alias: (*alias)(d), } - if err := d.DecodeElement(aux, &start); err != nil { + if err := dec.DecodeElement(aux, &start); err != nil { return err } d.ExpirationTime = (*time.Time)(aux.ExpirationTime) @@ -89,7 +89,7 @@ func (d *DequeuedMessageItem) UnmarshalXML(d *xml.Decoder, start xml.StartElemen } // MarshalXML implements the xml.Marshaller interface for type EnqueuedMessage. -func (e EnqueuedMessage) MarshalXML(e *xml.Encoder, start xml.StartElement) error { +func (e EnqueuedMessage) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { type alias EnqueuedMessage aux := &struct { *alias @@ -102,11 +102,11 @@ func (e EnqueuedMessage) MarshalXML(e *xml.Encoder, start xml.StartElement) erro InsertionTime: (*timeRFC1123)(e.InsertionTime), TimeNextVisible: (*timeRFC1123)(e.TimeNextVisible), } - return e.EncodeElement(aux, start) + return enc.EncodeElement(aux, start) } // UnmarshalXML implements the xml.Unmarshaller interface for type EnqueuedMessage. -func (e *EnqueuedMessage) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { +func (e *EnqueuedMessage) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { type alias EnqueuedMessage aux := &struct { *alias @@ -116,7 +116,7 @@ func (e *EnqueuedMessage) UnmarshalXML(d *xml.Decoder, start xml.StartElement) e }{ alias: (*alias)(e), } - if err := d.DecodeElement(aux, &start); err != nil { + if err := dec.DecodeElement(aux, &start); err != nil { return err } e.ExpirationTime = (*time.Time)(aux.ExpirationTime) @@ -126,7 +126,7 @@ func (e *EnqueuedMessage) UnmarshalXML(d *xml.Decoder, start xml.StartElement) e } // MarshalXML implements the xml.Marshaller interface for type GeoReplication. -func (g GeoReplication) MarshalXML(e *xml.Encoder, start xml.StartElement) error { +func (g GeoReplication) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { type alias GeoReplication aux := &struct { *alias @@ -135,11 +135,11 @@ func (g GeoReplication) MarshalXML(e *xml.Encoder, start xml.StartElement) error alias: (*alias)(&g), LastSyncTime: (*timeRFC1123)(g.LastSyncTime), } - return e.EncodeElement(aux, start) + return enc.EncodeElement(aux, start) } // UnmarshalXML implements the xml.Unmarshaller interface for type GeoReplication. -func (g *GeoReplication) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { +func (g *GeoReplication) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { type alias GeoReplication aux := &struct { *alias @@ -147,7 +147,7 @@ func (g *GeoReplication) UnmarshalXML(d *xml.Decoder, start xml.StartElement) er }{ alias: (*alias)(g), } - if err := d.DecodeElement(aux, &start); err != nil { + if err := dec.DecodeElement(aux, &start); err != nil { return err } g.LastSyncTime = (*time.Time)(aux.LastSyncTime) @@ -155,7 +155,7 @@ func (g *GeoReplication) UnmarshalXML(d *xml.Decoder, start xml.StartElement) er } // MarshalXML implements the xml.Marshaller interface for type ListQueuesSegmentResponse. -func (l ListQueuesSegmentResponse) MarshalXML(e *xml.Encoder, start xml.StartElement) error { +func (l ListQueuesSegmentResponse) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { type alias ListQueuesSegmentResponse aux := &struct { *alias @@ -166,11 +166,11 @@ func (l ListQueuesSegmentResponse) MarshalXML(e *xml.Encoder, start xml.StartEle if l.QueueItems != nil { aux.QueueItems = &l.QueueItems } - return e.EncodeElement(aux, start) + return enc.EncodeElement(aux, start) } // MarshalXML implements the xml.Marshaller interface for type PeekedMessageItem. -func (p PeekedMessageItem) MarshalXML(e *xml.Encoder, start xml.StartElement) error { +func (p PeekedMessageItem) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { type alias PeekedMessageItem aux := &struct { *alias @@ -181,11 +181,11 @@ func (p PeekedMessageItem) MarshalXML(e *xml.Encoder, start xml.StartElement) er ExpirationTime: (*timeRFC1123)(p.ExpirationTime), InsertionTime: (*timeRFC1123)(p.InsertionTime), } - return e.EncodeElement(aux, start) + return enc.EncodeElement(aux, start) } // UnmarshalXML implements the xml.Unmarshaller interface for type PeekedMessageItem. -func (p *PeekedMessageItem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { +func (p *PeekedMessageItem) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { type alias PeekedMessageItem aux := &struct { *alias @@ -194,7 +194,7 @@ func (p *PeekedMessageItem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) }{ alias: (*alias)(p), } - if err := d.DecodeElement(aux, &start); err != nil { + if err := dec.DecodeElement(aux, &start); err != nil { return err } p.ExpirationTime = (*time.Time)(aux.ExpirationTime) @@ -203,7 +203,7 @@ func (p *PeekedMessageItem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) } // UnmarshalXML implements the xml.Unmarshaller interface for type QueueItem. -func (q *QueueItem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { +func (q *QueueItem) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { type alias QueueItem aux := &struct { *alias @@ -211,7 +211,7 @@ func (q *QueueItem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { }{ alias: (*alias)(q), } - if err := d.DecodeElement(aux, &start); err != nil { + if err := dec.DecodeElement(aux, &start); err != nil { return err } q.Metadata = (map[string]*string)(aux.Metadata) @@ -246,7 +246,7 @@ func (s *StorageError) UnmarshalJSON(data []byte) error { } // MarshalXML implements the xml.Marshaller interface for type StorageServiceProperties. -func (s StorageServiceProperties) MarshalXML(e *xml.Encoder, start xml.StartElement) error { +func (s StorageServiceProperties) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { type alias StorageServiceProperties aux := &struct { *alias @@ -257,7 +257,7 @@ func (s StorageServiceProperties) MarshalXML(e *xml.Encoder, start xml.StartElem if s.Cors != nil { aux.Cors = &s.Cors } - return e.EncodeElement(aux, start) + return enc.EncodeElement(aux, start) } func populate(m map[string]interface{}, k string, v interface{}) { diff --git a/sdk/storage/azqueue/service/responses.go b/sdk/storage/azqueue/service/responses.go new file mode 100644 index 000000000000..6d43c3366ca3 --- /dev/null +++ b/sdk/storage/azqueue/service/responses.go @@ -0,0 +1 @@ +package service From 54c940a4ad0301ec03a1480261da16d721faa7ea Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Thu, 29 Dec 2022 14:56:28 -0800 Subject: [PATCH 08/17] regenrated and added pager --- sdk/storage/azqueue/go.mod | 6 +- sdk/storage/azqueue/service/client.go | 81 ++++++++++++++++++++++++ sdk/storage/azqueue/service/models.go | 6 ++ sdk/storage/azqueue/service/responses.go | 28 ++++++++ 4 files changed, 119 insertions(+), 2 deletions(-) diff --git a/sdk/storage/azqueue/go.mod b/sdk/storage/azqueue/go.mod index 8a24f5064305..82e36794a7c6 100644 --- a/sdk/storage/azqueue/go.mod +++ b/sdk/storage/azqueue/go.mod @@ -2,10 +2,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue go 1.19 -require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0 +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 +) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect golang.org/x/text v0.3.7 // indirect ) diff --git a/sdk/storage/azqueue/service/client.go b/sdk/storage/azqueue/service/client.go index b29e4a709982..0e4f501cb914 100644 --- a/sdk/storage/azqueue/service/client.go +++ b/sdk/storage/azqueue/service/client.go @@ -1,12 +1,15 @@ package service import ( + "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/base" "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/exported" "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/generated" "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/shared" + "net/http" ) // ClientOptions contains the optional parameters when creating a Client. @@ -73,3 +76,81 @@ func (s *Client) sharedKey() *SharedKeyCredential { func (s *Client) URL() string { return s.generated().Endpoint() } + +//func (s *Client) CreateQueue(ctx context.Context, containerName string, options *CreateContainerOptions) (CreateContainerResponse, error) { +// containerClient := s.NewContainerClient(containerName) +// containerCreateResp, err := containerClient.Create(ctx, options) +// return containerCreateResp, err +//} +// + +//func (s *Client) DeleteQueue(ctx context.Context, containerName string, options *DeleteContainerOptions) (DeleteContainerResponse, error) { +// containerClient := s.NewContainerClient(containerName) +// containerDeleteResp, err := containerClient.Delete(ctx, options) +// return containerDeleteResp, err +//} + +// GetProperties - gets the properties of a storage account's Queue service, including properties for Storage Analytics +// and CORS (Cross-Origin Resource Sharing) rules. +func (s *Client) GetProperties(ctx context.Context, o *GetPropertiesOptions) (GetPropertiesResponse, error) { + getPropertiesOptions := o.format() + resp, err := s.generated().GetProperties(ctx, getPropertiesOptions) + return resp, err +} + +// SetProperties Sets the properties of a storage account's Queue service, including Azure Storage Analytics. +// If an element (e.g. analytics_logging) is left as None, the existing settings on the service for that functionality are preserved. +func (s *Client) SetProperties(ctx context.Context, o *SetPropertiesOptions) (SetPropertiesResponse, error) { + properties, setPropertiesOptions := o.format() + resp, err := s.generated().SetProperties(ctx, properties, setPropertiesOptions) + return resp, err +} + +// GetStatistics Retrieves statistics related to replication for the Queue service. +func (s *Client) GetStatistics(ctx context.Context, o *GetStatisticsOptions) (GetStatisticsResponse, error) { + getStatisticsOptions := o.format() + resp, err := s.generated().GetStatistics(ctx, getStatisticsOptions) + + return resp, err +} + +// NewListQueuesPager operation returns a pager of the queues under the specified account. +// Use an empty Marker to start enumeration from the beginning. Queue names are returned in lexicographic order. +// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/list-queues1. +func (s *Client) NewListQueuesPager(o *ListQueuesOptions) *runtime.Pager[ListQueuesResponse] { + listOptions := generated.ServiceClientListQueuesSegmentOptions{} + if o != nil { + if o.Include.Metadata { + listOptions.Include = append(listOptions.Include, "metadata") + } + listOptions.Marker = o.Marker + listOptions.Maxresults = o.MaxResults + listOptions.Prefix = o.Prefix + } + return runtime.NewPager(runtime.PagingHandler[ListQueuesResponse]{ + More: func(page ListQueuesResponse) bool { + return page.NextMarker != nil && len(*page.NextMarker) > 0 + }, + Fetcher: func(ctx context.Context, page *ListQueuesResponse) (ListQueuesResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = s.generated().ListQueuesSegmentCreateRequest(ctx, &listOptions) + } else { + listOptions.Marker = page.Marker + req, err = s.generated().ListQueuesSegmentCreateRequest(ctx, &listOptions) + } + if err != nil { + return ListQueuesResponse{}, err + } + resp, err := s.generated().Pipeline().Do(req) + if err != nil { + return ListQueuesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ListQueuesResponse{}, runtime.NewResponseError(resp) + } + return s.generated().ListQueuesSegmentHandleResponse(resp) + }, + }) +} diff --git a/sdk/storage/azqueue/service/models.go b/sdk/storage/azqueue/service/models.go index 02dc858a972e..7c3cd8cfd423 100644 --- a/sdk/storage/azqueue/service/models.go +++ b/sdk/storage/azqueue/service/models.go @@ -32,6 +32,12 @@ type Metrics = generated.Metrics // Logging - Azure Analytics Logging settings. type Logging = generated.Logging +//// CreateContainerOptions contains the optional parameters for the container.Client.Create method. +//type CreateQueueOptions = container.CreateOptions +// +//// DeleteContainerOptions contains the optional parameters for the container.Client.Delete method. +//type DeleteQueueOptions = container.DeleteOptions + // StorageServiceProperties - Storage Service Properties. type StorageServiceProperties = generated.StorageServiceProperties diff --git a/sdk/storage/azqueue/service/responses.go b/sdk/storage/azqueue/service/responses.go index 6d43c3366ca3..b377dc69e4a1 100644 --- a/sdk/storage/azqueue/service/responses.go +++ b/sdk/storage/azqueue/service/responses.go @@ -1 +1,29 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + package service + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/generated" +) + +// CreateQueueResponse contains the response from method container.Client.Create. +type CreateQueueResponse = generated.QueueClientCreateResponse + +// DeleteQueueResponse contains the response from method container.Client.Delete +type DeleteQueueResponse = generated.QueueClientDeleteResponse + +// ListQueuesResponse contains the response from method Client.ListQueuesSegment. +type ListQueuesResponse = generated.ServiceClientListQueuesSegmentResponse + +// GetPropertiesResponse contains the response from method Client.GetProperties. +type GetPropertiesResponse = generated.ServiceClientGetPropertiesResponse + +// SetPropertiesResponse contains the response from method Client.SetProperties. +type SetPropertiesResponse = generated.ServiceClientSetPropertiesResponse + +// GetStatisticsResponse contains the response from method Client.GetStatistics. +type GetStatisticsResponse = generated.ServiceClientGetStatisticsResponse From 4ea9e09656da04de5969da13d61627544f057e96 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Thu, 29 Dec 2022 15:00:01 -0800 Subject: [PATCH 09/17] autorest comment change --- sdk/storage/azqueue/internal/generated/autorest.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azqueue/internal/generated/autorest.md b/sdk/storage/azqueue/internal/generated/autorest.md index cff0ad9a3aad..830046f50f3c 100644 --- a/sdk/storage/azqueue/internal/generated/autorest.md +++ b/sdk/storage/azqueue/internal/generated/autorest.md @@ -69,7 +69,7 @@ directive: replace(/\(client \*ServiceClient\) listQueuesSegmentHandleResponse\(/, `(client *ServiceClient) ListQueuesSegmentHandleResponse(`); ``` -### Fix function marshal and unmarshal signatures to be non-conflicting +### Fix encoder and decoder parameter names to be non-conflicting ``` yaml directive: From e7a272c896e5c7741a28281722beb41fdd60fdad Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Fri, 30 Dec 2022 12:44:14 -0800 Subject: [PATCH 10/17] comments --- sdk/storage/azqueue/service/client.go | 14 ++------------ sdk/storage/azqueue/service/models.go | 7 ++----- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/sdk/storage/azqueue/service/client.go b/sdk/storage/azqueue/service/client.go index 0e4f501cb914..fd9e95a5c4bb 100644 --- a/sdk/storage/azqueue/service/client.go +++ b/sdk/storage/azqueue/service/client.go @@ -77,18 +77,8 @@ func (s *Client) URL() string { return s.generated().Endpoint() } -//func (s *Client) CreateQueue(ctx context.Context, containerName string, options *CreateContainerOptions) (CreateContainerResponse, error) { -// containerClient := s.NewContainerClient(containerName) -// containerCreateResp, err := containerClient.Create(ctx, options) -// return containerCreateResp, err -//} -// - -//func (s *Client) DeleteQueue(ctx context.Context, containerName string, options *DeleteContainerOptions) (DeleteContainerResponse, error) { -// containerClient := s.NewContainerClient(containerName) -// containerDeleteResp, err := containerClient.Delete(ctx, options) -// return containerDeleteResp, err -//} +// TODO: CreateQueue +// TODO: DeleteQueue // GetProperties - gets the properties of a storage account's Queue service, including properties for Storage Analytics // and CORS (Cross-Origin Resource Sharing) rules. diff --git a/sdk/storage/azqueue/service/models.go b/sdk/storage/azqueue/service/models.go index 7c3cd8cfd423..1c1ed14cfc95 100644 --- a/sdk/storage/azqueue/service/models.go +++ b/sdk/storage/azqueue/service/models.go @@ -32,11 +32,8 @@ type Metrics = generated.Metrics // Logging - Azure Analytics Logging settings. type Logging = generated.Logging -//// CreateContainerOptions contains the optional parameters for the container.Client.Create method. -//type CreateQueueOptions = container.CreateOptions -// -//// DeleteContainerOptions contains the optional parameters for the container.Client.Delete method. -//type DeleteQueueOptions = container.DeleteOptions +// TODO: CreateQueueOptions = queue.CreateOptions +// TODO: DeleteQueueOptions = queue.DeleteOptions // StorageServiceProperties - Storage Service Properties. type StorageServiceProperties = generated.StorageServiceProperties From dbd179d8919230e45638ce607adae2b00e0a715f Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Fri, 30 Dec 2022 12:46:24 -0800 Subject: [PATCH 11/17] comments --- sdk/storage/azqueue/service/responses.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/storage/azqueue/service/responses.go b/sdk/storage/azqueue/service/responses.go index b377dc69e4a1..1f4f97df6457 100644 --- a/sdk/storage/azqueue/service/responses.go +++ b/sdk/storage/azqueue/service/responses.go @@ -10,10 +10,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/generated" ) -// CreateQueueResponse contains the response from method container.Client.Create. +// CreateQueueResponse contains the response from method queue.Client.Create. type CreateQueueResponse = generated.QueueClientCreateResponse -// DeleteQueueResponse contains the response from method container.Client.Delete +// DeleteQueueResponse contains the response from method queue.Client.Delete type DeleteQueueResponse = generated.QueueClientDeleteResponse // ListQueuesResponse contains the response from method Client.ListQueuesSegment. From 6a2741ba07d52c3f502048c4b8e117a578003b29 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Fri, 30 Dec 2022 12:59:08 -0800 Subject: [PATCH 12/17] comments --- sdk/storage/azqueue/service/client.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/storage/azqueue/service/client.go b/sdk/storage/azqueue/service/client.go index fd9e95a5c4bb..591a4ac976c1 100644 --- a/sdk/storage/azqueue/service/client.go +++ b/sdk/storage/azqueue/service/client.go @@ -144,3 +144,5 @@ func (s *Client) NewListQueuesPager(o *ListQueuesOptions) *runtime.Pager[ListQue }, }) } + +// TODO: GetSASURL() From 4bd021feea7cce24cad0e1314c652d6fce92771e Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Mon, 9 Jan 2023 19:24:01 -0800 Subject: [PATCH 13/17] version change --- sdk/storage/azqueue/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azqueue/go.mod b/sdk/storage/azqueue/go.mod index 82e36794a7c6..5dcf20fc113e 100644 --- a/sdk/storage/azqueue/go.mod +++ b/sdk/storage/azqueue/go.mod @@ -1,6 +1,6 @@ module github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue -go 1.19 +go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0 From 8266bdb236125f8dac6c8978cb0eb3ecd8ceb084 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Mon, 9 Jan 2023 20:24:41 -0800 Subject: [PATCH 14/17] marker --- sdk/storage/azqueue/service/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azqueue/service/client.go b/sdk/storage/azqueue/service/client.go index 591a4ac976c1..0586423fd559 100644 --- a/sdk/storage/azqueue/service/client.go +++ b/sdk/storage/azqueue/service/client.go @@ -127,7 +127,7 @@ func (s *Client) NewListQueuesPager(o *ListQueuesOptions) *runtime.Pager[ListQue if page == nil { req, err = s.generated().ListQueuesSegmentCreateRequest(ctx, &listOptions) } else { - listOptions.Marker = page.Marker + listOptions.Marker = page.NextMarker req, err = s.generated().ListQueuesSegmentCreateRequest(ctx, &listOptions) } if err != nil { From e6af36eba416492b8ef3735837a5c1bb16a35e62 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Tue, 10 Jan 2023 13:49:13 -0800 Subject: [PATCH 15/17] rename to queue --- sdk/storage/azqueue/{service => queue}/client.go | 2 +- sdk/storage/azqueue/{service => queue}/models.go | 2 +- sdk/storage/azqueue/{service => queue}/responses.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename sdk/storage/azqueue/{service => queue}/client.go (99%) rename sdk/storage/azqueue/{service => queue}/models.go (99%) rename sdk/storage/azqueue/{service => queue}/responses.go (98%) diff --git a/sdk/storage/azqueue/service/client.go b/sdk/storage/azqueue/queue/client.go similarity index 99% rename from sdk/storage/azqueue/service/client.go rename to sdk/storage/azqueue/queue/client.go index 0586423fd559..85aff8fd8032 100644 --- a/sdk/storage/azqueue/service/client.go +++ b/sdk/storage/azqueue/queue/client.go @@ -1,4 +1,4 @@ -package service +package queue import ( "context" diff --git a/sdk/storage/azqueue/service/models.go b/sdk/storage/azqueue/queue/models.go similarity index 99% rename from sdk/storage/azqueue/service/models.go rename to sdk/storage/azqueue/queue/models.go index 1c1ed14cfc95..0f5be5bf38f8 100644 --- a/sdk/storage/azqueue/service/models.go +++ b/sdk/storage/azqueue/queue/models.go @@ -1,4 +1,4 @@ -package service +package queue import ( "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/exported" diff --git a/sdk/storage/azqueue/service/responses.go b/sdk/storage/azqueue/queue/responses.go similarity index 98% rename from sdk/storage/azqueue/service/responses.go rename to sdk/storage/azqueue/queue/responses.go index 1f4f97df6457..781d385eb251 100644 --- a/sdk/storage/azqueue/service/responses.go +++ b/sdk/storage/azqueue/queue/responses.go @@ -4,7 +4,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -package service +package queue import ( "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/generated" From 06e5d829df444795d5b22874ad94576a6a06dcda Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Tue, 10 Jan 2023 13:59:30 -0800 Subject: [PATCH 16/17] further cleanup --- sdk/storage/azqueue/{queue => }/models.go | 8 +++++++- sdk/storage/azqueue/{queue => }/responses.go | 2 +- .../azqueue/{queue/client.go => service_client.go} | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) rename sdk/storage/azqueue/{queue => }/models.go (96%) rename sdk/storage/azqueue/{queue => }/responses.go (98%) rename sdk/storage/azqueue/{queue/client.go => service_client.go} (96%) diff --git a/sdk/storage/azqueue/queue/models.go b/sdk/storage/azqueue/models.go similarity index 96% rename from sdk/storage/azqueue/queue/models.go rename to sdk/storage/azqueue/models.go index 0f5be5bf38f8..e570dd648adc 100644 --- a/sdk/storage/azqueue/queue/models.go +++ b/sdk/storage/azqueue/models.go @@ -1,4 +1,10 @@ -package queue +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package azqueue import ( "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/exported" diff --git a/sdk/storage/azqueue/queue/responses.go b/sdk/storage/azqueue/responses.go similarity index 98% rename from sdk/storage/azqueue/queue/responses.go rename to sdk/storage/azqueue/responses.go index 781d385eb251..9a35cb46afd1 100644 --- a/sdk/storage/azqueue/queue/responses.go +++ b/sdk/storage/azqueue/responses.go @@ -4,7 +4,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -package queue +package azqueue import ( "github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue/internal/generated" diff --git a/sdk/storage/azqueue/queue/client.go b/sdk/storage/azqueue/service_client.go similarity index 96% rename from sdk/storage/azqueue/queue/client.go rename to sdk/storage/azqueue/service_client.go index 85aff8fd8032..50568048adba 100644 --- a/sdk/storage/azqueue/queue/client.go +++ b/sdk/storage/azqueue/service_client.go @@ -1,4 +1,10 @@ -package queue +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package azqueue import ( "context" From 677736abb5ff0542bd0f9844c483507547b3ae2f Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Tue, 10 Jan 2023 14:08:15 -0800 Subject: [PATCH 17/17] rename service client --- sdk/storage/azqueue/{service_client.go => client.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sdk/storage/azqueue/{service_client.go => client.go} (100%) diff --git a/sdk/storage/azqueue/service_client.go b/sdk/storage/azqueue/client.go similarity index 100% rename from sdk/storage/azqueue/service_client.go rename to sdk/storage/azqueue/client.go