From 3228b2ce850a2af18c946641f83fe07cfd432f4f Mon Sep 17 00:00:00 2001 From: Tamer Sherif <69483382+tasherif-msft@users.noreply.github.com> Date: Wed, 28 Dec 2022 12:23:16 -0800 Subject: [PATCH] Generate Code for AzQueue (#19729) * first generation * removed queuename from url param * fixed georep * removed pagination * move to internal * last generation --- sdk/storage/azqueue/go.mod | 11 + sdk/storage/azqueue/go.sum | 12 + .../azqueue/internal/generated/autorest.md | 70 +++ .../internal/generated/zz_constants.go | 155 +++++++ .../internal/generated/zz_messageid_client.go | 177 ++++++++ .../internal/generated/zz_messages_client.go | 296 ++++++++++++ .../azqueue/internal/generated/zz_models.go | 425 ++++++++++++++++++ .../internal/generated/zz_models_serde.go | 282 ++++++++++++ .../internal/generated/zz_queue_client.go | 422 +++++++++++++++++ .../internal/generated/zz_response_types.go | 226 ++++++++++ .../internal/generated/zz_service_client.go | 273 +++++++++++ .../internal/generated/zz_time_rfc1123.go | 47 ++ .../internal/generated/zz_time_rfc3339.go | 63 +++ .../internal/generated/zz_xml_helper.go | 42 ++ 14 files changed, 2501 insertions(+) create mode 100644 sdk/storage/azqueue/go.mod create mode 100644 sdk/storage/azqueue/go.sum create mode 100644 sdk/storage/azqueue/internal/generated/autorest.md create mode 100644 sdk/storage/azqueue/internal/generated/zz_constants.go create mode 100644 sdk/storage/azqueue/internal/generated/zz_messageid_client.go create mode 100644 sdk/storage/azqueue/internal/generated/zz_messages_client.go create mode 100644 sdk/storage/azqueue/internal/generated/zz_models.go create mode 100644 sdk/storage/azqueue/internal/generated/zz_models_serde.go create mode 100644 sdk/storage/azqueue/internal/generated/zz_queue_client.go create mode 100644 sdk/storage/azqueue/internal/generated/zz_response_types.go create mode 100644 sdk/storage/azqueue/internal/generated/zz_service_client.go create mode 100644 sdk/storage/azqueue/internal/generated/zz_time_rfc1123.go create mode 100644 sdk/storage/azqueue/internal/generated/zz_time_rfc3339.go create mode 100644 sdk/storage/azqueue/internal/generated/zz_xml_helper.go 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/generated/autorest.md b/sdk/storage/azqueue/internal/generated/autorest.md new file mode 100644 index 000000000000..e75176d443e5 --- /dev/null +++ b/sdk/storage/azqueue/internal/generated/autorest.md @@ -0,0 +1,70 @@ +# Code Generation - Azure Queue 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" +``` + + +### 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"))}); + } + } +``` + +### Fix GeoReplication + +``` yaml +directive: +- from: swagger-document + where: $.definitions + transform: > + delete $.GeoReplication.properties.Status["x-ms-enum"]; + $.GeoReplication.properties.Status["x-ms-enum"] = { + "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 ListQueuesFlatSegment ListQueuesSegment`). + replace(/\(client \*ServiceClient\) listQueuesSegmentCreateRequest\(/, `(client *ServiceClient) ListQueuesSegmentCreateRequest(`). + replace(/\(client \*ServiceClient\) listQueuesSegmentHandleResponse\(/, `(client *ServiceClient) ListQueuesSegmentHandleResponse(`); +``` \ No newline at end of file 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..ea5e119d0ab1 --- /dev/null +++ b/sdk/storage/azqueue/internal/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 + +// 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/generated/zz_messageid_client.go b/sdk/storage/azqueue/internal/generated/zz_messageid_client.go new file mode 100644 index 000000000000..4ca438d95364 --- /dev/null +++ b/sdk/storage/azqueue/internal/generated/zz_messageid_client.go @@ -0,0 +1,177 @@ +//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" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strconv" + "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 +// 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, popReceipt string, options *MessageIDClientDeleteOptions) (MessageIDClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, 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, popReceipt string, options *MessageIDClientDeleteOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodDelete, client.endpoint) + 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 +// 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, 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 + } + 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, 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 + } + 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/internal/generated/zz_messages_client.go b/sdk/storage/azqueue/internal/generated/zz_messages_client.go new file mode 100644 index 000000000000..cde60d45c159 --- /dev/null +++ b/sdk/storage/azqueue/internal/generated/zz_messages_client.go @@ -0,0 +1,296 @@ +//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" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strconv" + "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 +// options - MessagesClientClearOptions contains the optional parameters for the MessagesClient.Clear method. +func (client *MessagesClient) Clear(ctx context.Context, options *MessagesClientClearOptions) (MessagesClientClearResponse, error) { + req, err := client.clearCreateRequest(ctx, 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, options *MessagesClientClearOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodDelete, client.endpoint) + 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 +// options - MessagesClientDequeueOptions contains the optional parameters for the MessagesClient.Dequeue method. +func (client *MessagesClient) Dequeue(ctx context.Context, options *MessagesClientDequeueOptions) (MessagesClientDequeueResponse, error) { + req, err := client.dequeueCreateRequest(ctx, 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, options *MessagesClientDequeueOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodGet, client.endpoint) + 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 +// 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, queueMessage QueueMessage, options *MessagesClientEnqueueOptions) (MessagesClientEnqueueResponse, error) { + req, err := client.enqueueCreateRequest(ctx, 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, queueMessage QueueMessage, options *MessagesClientEnqueueOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodPost, client.endpoint) + 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 +// options - MessagesClientPeekOptions contains the optional parameters for the MessagesClient.Peek method. +func (client *MessagesClient) Peek(ctx context.Context, options *MessagesClientPeekOptions) (MessagesClientPeekResponse, error) { + req, err := client.peekCreateRequest(ctx, 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, options *MessagesClientPeekOptions) (*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("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/internal/generated/zz_models.go b/sdk/storage/azqueue/internal/generated/zz_models.go new file mode 100644 index 000000000000..a58cf599fe83 --- /dev/null +++ b/sdk/storage/azqueue/internal/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 *QueueGeoReplicationStatus `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/internal/generated/zz_models_serde.go b/sdk/storage/azqueue/internal/generated/zz_models_serde.go new file mode 100644 index 000000000000..e34236f6e5b3 --- /dev/null +++ b/sdk/storage/azqueue/internal/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/internal/generated/zz_queue_client.go b/sdk/storage/azqueue/internal/generated/zz_queue_client.go new file mode 100644 index 000000000000..1b14000267ef --- /dev/null +++ b/sdk/storage/azqueue/internal/generated/zz_queue_client.go @@ -0,0 +1,422 @@ +//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" + "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" +) + +// 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 +// options - QueueClientCreateOptions contains the optional parameters for the QueueClient.Create method. +func (client *QueueClient) Create(ctx context.Context, options *QueueClientCreateOptions) (QueueClientCreateResponse, error) { + req, err := client.createCreateRequest(ctx, 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, options *QueueClientCreateOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodPut, client.endpoint) + 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 +// options - QueueClientDeleteOptions contains the optional parameters for the QueueClient.Delete method. +func (client *QueueClient) Delete(ctx context.Context, options *QueueClientDeleteOptions) (QueueClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, 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, options *QueueClientDeleteOptions) (*policy.Request, error) { + req, err := runtime.NewRequest(ctx, http.MethodDelete, client.endpoint) + 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 +// options - QueueClientGetAccessPolicyOptions contains the optional parameters for the QueueClient.GetAccessPolicy method. +func (client *QueueClient) GetAccessPolicy(ctx context.Context, options *QueueClientGetAccessPolicyOptions) (QueueClientGetAccessPolicyResponse, error) { + req, err := client.getAccessPolicyCreateRequest(ctx, 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, options *QueueClientGetAccessPolicyOptions) (*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", "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 +// options - QueueClientGetPropertiesOptions contains the optional parameters for the QueueClient.GetProperties method. +func (client *QueueClient) GetProperties(ctx context.Context, options *QueueClientGetPropertiesOptions) (QueueClientGetPropertiesResponse, error) { + req, err := client.getPropertiesCreateRequest(ctx, 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, options *QueueClientGetPropertiesOptions) (*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", "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 +// queueACL - the acls for the queue +// options - QueueClientSetAccessPolicyOptions contains the optional parameters for the QueueClient.SetAccessPolicy method. +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 + } + 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, queueACL []*SignedIdentifier, options *QueueClientSetAccessPolicyOptions) (*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("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 +// options - QueueClientSetMetadataOptions contains the optional parameters for the QueueClient.SetMetadata method. +func (client *QueueClient) SetMetadata(ctx context.Context, options *QueueClientSetMetadataOptions) (QueueClientSetMetadataResponse, error) { + req, err := client.setMetadataCreateRequest(ctx, 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, options *QueueClientSetMetadataOptions) (*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("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/internal/generated/zz_response_types.go b/sdk/storage/azqueue/internal/generated/zz_response_types.go new file mode 100644 index 000000000000..128459f4704c --- /dev/null +++ b/sdk/storage/azqueue/internal/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/internal/generated/zz_service_client.go b/sdk/storage/azqueue/internal/generated/zz_service_client.go new file mode 100644 index 000000000000..93f33e123968 --- /dev/null +++ b/sdk/storage/azqueue/internal/generated/zz_service_client.go @@ -0,0 +1,273 @@ +//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. +// ListQueuesSegmentCreateRequest creates the ListQueuesFlatSegment 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 + } + 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/internal/generated/zz_time_rfc1123.go b/sdk/storage/azqueue/internal/generated/zz_time_rfc1123.go new file mode 100644 index 000000000000..6fb227e0d505 --- /dev/null +++ b/sdk/storage/azqueue/internal/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/internal/generated/zz_time_rfc3339.go b/sdk/storage/azqueue/internal/generated/zz_time_rfc3339.go new file mode 100644 index 000000000000..e19af161526c --- /dev/null +++ b/sdk/storage/azqueue/internal/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/internal/generated/zz_xml_helper.go b/sdk/storage/azqueue/internal/generated/zz_xml_helper.go new file mode 100644 index 000000000000..c517807bd03a --- /dev/null +++ b/sdk/storage/azqueue/internal/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 +}