Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions sdk/storage/azure-storage-queue/customization/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.azure</groupId>
<artifactId>azure-code-customization-parent</artifactId>
<version>1.0.0-beta.1</version> <!-- {x-version-update;com.azure:azure-code-customization-parent;current} -->
<relativePath>../../../parents/azure-code-customization-parent</relativePath>
</parent>

<name>Microsoft Azure Queue Storage client customization for Java</name>
<description>This package contains client customization for Microsoft Azure Queue Storage</description>

<groupId>com.azure.tools</groupId>
<artifactId>azure-storage-queue-customization</artifactId>
<version>1.0.0-beta.1</version>
<packaging>jar</packaging>
</project>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ private AzureQueueStorageImpl createAzureQueueStorageImpl(QueueServiceVersion ve
endpoint, retryOptions, coreRetryOptions, logOptions, clientOptions, httpClient, perCallPolicies,
perRetryPolicies, configuration, audience, LOGGER);

return new AzureQueueStorageImpl(pipeline, endpoint, version.getVersion());
return new AzureQueueStorageImpl(pipeline, endpoint + "/" + queueName, version);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
Comment on lines 10 to 14
import com.azure.core.util.Context;
Expand All @@ -22,6 +23,7 @@
import com.azure.storage.common.sas.AccountSasSignatureValues;
import com.azure.storage.queue.implementation.AzureQueueStorageImpl;
import com.azure.storage.queue.implementation.models.KeyInfo;
import com.azure.storage.queue.implementation.util.ModelHelper;
import com.azure.storage.queue.models.QueueCorsRule;
import com.azure.storage.queue.models.QueueGetUserDelegationKeyOptions;
import com.azure.storage.queue.models.QueueItem;
Expand Down Expand Up @@ -132,9 +134,11 @@ public QueueMessageEncoding getMessageEncoding() {
* @return QueueAsyncClient that interacts with the specified queue
*/
public QueueAsyncClient getQueueAsyncClient(String queueName) {
QueueClient queueClient = new QueueClient(client, queueName, accountName, serviceVersion, messageEncoding,
AzureQueueStorageImpl queueStorage = new AzureQueueStorageImpl(client.getHttpPipeline(),
client.getSerializerAdapter(), client.getUrl() + "/" + queueName, client.getServiceVersion());
QueueClient queueClient = new QueueClient(queueStorage, queueName, accountName, serviceVersion, messageEncoding,
processMessageDecodingErrorAsyncHandler, processMessageDecodingErrorHandler, null);
return new QueueAsyncClient(client, queueName, accountName, serviceVersion, messageEncoding,
return new QueueAsyncClient(queueStorage, queueName, accountName, serviceVersion, messageEncoding,
processMessageDecodingErrorAsyncHandler, processMessageDecodingErrorHandler, queueClient);
}

Expand Down Expand Up @@ -349,9 +353,9 @@ PagedFlux<QueueItem> listQueuesWithOptionalTimeout(String marker, QueuesSegmentO

BiFunction<String, Integer, Mono<PagedResponse<QueueItem>>> retriever = (nextMarker,
pageSize) -> StorageImplUtils.applyOptionalTimeout(this.client.getServices()
.listQueuesSegmentSinglePageAsync(prefix, nextMarker, pageSize == null ? maxResultsPerPage : pageSize,
include, null, null, context),
timeout);
.getQueuesWithResponseAsync(ModelHelper.listQueuesRequestOptions(context, prefix, nextMarker,
pageSize == null ? maxResultsPerPage : pageSize, include))
.map(ModelHelper::toQueueItemPage), timeout);

return new PagedFlux<>(pageSize -> retriever.apply(marker, pageSize), retriever);
}
Expand Down Expand Up @@ -420,10 +424,10 @@ public Mono<Response<QueueServiceProperties>> getPropertiesWithResponse() {
}

Mono<Response<QueueServiceProperties>> getPropertiesWithResponse(Context context) {
context = context == null ? Context.NONE : context;
return client.getServices()
.getPropertiesWithResponseAsync(null, null, context)
.map(response -> new SimpleResponse<>(response, response.getValue()));
.getPropertiesWithResponseAsync(ModelHelper.requestOptions(context))
.map(response -> new SimpleResponse<>(response,
ModelHelper.deserializeXmlBody(response.getValue(), QueueServiceProperties::fromXml)));
}

/**
Expand Down Expand Up @@ -545,8 +549,9 @@ public Mono<Response<Void>> setPropertiesWithResponse(QueueServiceProperties pro
}

Mono<Response<Void>> setPropertiesWithResponse(QueueServiceProperties properties, Context context) {
context = context == null ? Context.NONE : context;
return client.getServices().setPropertiesNoCustomHeadersWithResponseAsync(properties, null, null, context);
return client.getServices()
.setPropertiesWithResponseAsync(ModelHelper.serializeXmlBody(properties),
ModelHelper.requestOptions(context));
}

/**
Expand Down Expand Up @@ -609,10 +614,10 @@ public Mono<Response<QueueServiceStatistics>> getStatisticsWithResponse() {
}

Mono<Response<QueueServiceStatistics>> getStatisticsWithResponse(Context context) {
context = context == null ? Context.NONE : context;
return client.getServices()
.getStatisticsWithResponseAsync(null, null, context)
.map(response -> new SimpleResponse<>(response, response.getValue()));
.getStatisticsWithResponseAsync(ModelHelper.requestOptions(context))
.map(response -> new SimpleResponse<>(response,
ModelHelper.deserializeXmlBody(response.getValue(), QueueServiceStatistics::fromXml)));
}

/**
Expand Down Expand Up @@ -788,12 +793,11 @@ Mono<Response<UserDelegationKey>> getUserDelegationKeyWithResponse(OffsetDateTim
new IllegalArgumentException("`start` must be null or a datetime before `expiry`."));
}

KeyInfo keyInfo = new KeyInfo(expiry).setStart(start).setDelegatedUserTenantId(delegatedUserTenantId);
return client.getServices()
.getUserDelegationKeyWithResponseAsync(
new KeyInfo().setStart(start == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(start))
.setExpiry(Constants.ISO_8601_UTC_DATE_FORMATTER.format(expiry))
.setDelegatedUserTenantId(delegatedUserTenantId),
null, null, context)
.map(rb -> new SimpleResponse<>(rb, rb.getValue()));
.getUserDelegationKeyWithResponseAsync(ModelHelper.serializeXmlBody(keyInfo),
ModelHelper.requestOptions(context))
.map(rb -> new SimpleResponse<>(rb,
ModelHelper.deserializeXmlBody(rb.getValue(), UserDelegationKey::fromXml)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.ResponseBase;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.storage.common.StorageSharedKeyCredential;
Expand All @@ -21,6 +22,7 @@
import com.azure.storage.common.implementation.StorageImplUtils;
import com.azure.storage.common.sas.AccountSasSignatureValues;
import com.azure.storage.queue.implementation.AzureQueueStorageImpl;
import com.azure.storage.queue.implementation.util.ModelHelper;
import com.azure.storage.queue.implementation.models.KeyInfo;
import com.azure.storage.queue.implementation.models.ServicesGetStatisticsHeaders;
import com.azure.storage.queue.implementation.models.ServicesGetUserDelegationKeyHeaders;
Expand Down Expand Up @@ -141,10 +143,12 @@ public QueueMessageEncoding getMessageEncoding() {
* @return QueueClient that interacts with the specified queue
*/
public QueueClient getQueueClient(String queueName) {
QueueAsyncClient queueAsyncClient
= new QueueAsyncClient(this.azureQueueStorage, queueName, accountName, serviceVersion, messageEncoding,
processMessageDecodingErrorAsyncHandler, processMessageDecodingErrorHandler, null);
return new QueueClient(this.azureQueueStorage, queueName, accountName, serviceVersion, messageEncoding,
AzureQueueStorageImpl queueStorage = new AzureQueueStorageImpl(this.azureQueueStorage.getHttpPipeline(),
this.azureQueueStorage.getSerializerAdapter(), this.azureQueueStorage.getUrl() + "/" + queueName,
this.azureQueueStorage.getServiceVersion());
QueueAsyncClient queueAsyncClient = new QueueAsyncClient(queueStorage, queueName, accountName, serviceVersion,
messageEncoding, processMessageDecodingErrorAsyncHandler, processMessageDecodingErrorHandler, null);
return new QueueClient(queueStorage, queueName, accountName, serviceVersion, messageEncoding,
processMessageDecodingErrorAsyncHandler, processMessageDecodingErrorHandler, queueAsyncClient);
}

Expand Down Expand Up @@ -335,9 +339,10 @@ public PagedIterable<QueueItem> listQueues(QueuesSegmentOptions options, Duratio
}
}
BiFunction<String, Integer, PagedResponse<QueueItem>> retriever = (nextMarker, pageSize) -> {
Supplier<PagedResponse<QueueItem>> operation = () -> this.azureQueueStorage.getServices()
.listQueuesSegmentSinglePage(prefix, nextMarker, pageSize == null ? maxResultsPerPage : pageSize,
include, null, null, finalContext);
Supplier<PagedResponse<QueueItem>> operation
= () -> ModelHelper.toQueueItemPage(this.azureQueueStorage.getServices()
.getQueuesWithResponse(ModelHelper.listQueuesRequestOptions(finalContext, prefix, nextMarker,
pageSize == null ? maxResultsPerPage : pageSize, include)));

return submitThreadPool(operation, LOGGER, timeout);

Expand Down Expand Up @@ -403,8 +408,12 @@ public QueueServiceProperties getProperties() {
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<QueueServiceProperties> getPropertiesWithResponse(Duration timeout, Context context) {
Context finalContext = context == null ? Context.NONE : context;
Supplier<Response<QueueServiceProperties>> operation
= () -> this.azureQueueStorage.getServices().getPropertiesWithResponse(null, null, finalContext);
Supplier<Response<QueueServiceProperties>> operation = () -> {
Response<BinaryData> response = this.azureQueueStorage.getServices()
.getPropertiesWithResponse(ModelHelper.requestOptions(finalContext));
return new SimpleResponse<>(response,
ModelHelper.deserializeXmlBody(response.getValue(), QueueServiceProperties::fromXml));
};

return submitThreadPool(operation, LOGGER, timeout);
}
Expand Down Expand Up @@ -538,7 +547,8 @@ public Response<Void> setPropertiesWithResponse(QueueServiceProperties propertie
Context context) {
Context finalContext = context == null ? Context.NONE : context;
Supplier<Response<Void>> operation = () -> this.azureQueueStorage.getServices()
.setPropertiesNoCustomHeadersWithResponse(properties, null, null, finalContext);
.setPropertiesWithResponse(ModelHelper.serializeXmlBody(properties),
ModelHelper.requestOptions(finalContext));

return submitThreadPool(operation, LOGGER, timeout);
}
Expand Down Expand Up @@ -596,8 +606,12 @@ public QueueServiceStatistics getStatistics() {
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<QueueServiceStatistics> getStatisticsWithResponse(Duration timeout, Context context) {
Context finalContext = context == null ? Context.NONE : context;
Supplier<ResponseBase<ServicesGetStatisticsHeaders, QueueServiceStatistics>> operation
= () -> this.azureQueueStorage.getServices().getStatisticsWithResponse(null, null, finalContext);
Supplier<Response<QueueServiceStatistics>> operation = () -> {
Response<BinaryData> response = this.azureQueueStorage.getServices()
.getStatisticsWithResponse(ModelHelper.requestOptions(finalContext));
return new SimpleResponse<>(response,
ModelHelper.deserializeXmlBody(response.getValue(), QueueServiceStatistics::fromXml));
};
return submitThreadPool(operation, LOGGER, timeout);
}

Expand Down Expand Up @@ -754,17 +768,16 @@ public Response<UserDelegationKey> getUserDelegationKeyWithResponse(QueueGetUser
new IllegalArgumentException("`start` must be null or a datetime before `expiry`."));
}

Callable<ResponseBase<ServicesGetUserDelegationKeyHeaders, UserDelegationKey>> operation
= () -> this.azureQueueStorage.getServices()
.getUserDelegationKeyWithResponse(new KeyInfo()
.setStart(options.getStartsOn() == null
? ""
: Constants.ISO_8601_UTC_DATE_FORMATTER.format(options.getStartsOn()))
.setExpiry(Constants.ISO_8601_UTC_DATE_FORMATTER.format(options.getExpiresOn()))
.setDelegatedUserTenantId(options.getDelegatedUserTenantId()), null, null, finalContext);

ResponseBase<ServicesGetUserDelegationKeyHeaders, UserDelegationKey> response
= sendRequest(operation, timeout, QueueStorageException.class);
KeyInfo keyInfo = new KeyInfo(options.getExpiresOn()).setStart(options.getStartsOn())
.setDelegatedUserTenantId(options.getDelegatedUserTenantId());
Callable<Response<UserDelegationKey>> operation = () -> {
Response<BinaryData> rb = this.azureQueueStorage.getServices()
.getUserDelegationKeyWithResponse(ModelHelper.serializeXmlBody(keyInfo),
ModelHelper.requestOptions(finalContext));
return new SimpleResponse<>(rb, ModelHelper.deserializeXmlBody(rb.getValue(), UserDelegationKey::fromXml));
};

Response<UserDelegationKey> response = sendRequest(operation, timeout, QueueStorageException.class);
return new SimpleResponse<>(response, response.getValue());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ private AzureQueueStorageImpl createAzureQueueStorageImpl(QueueServiceVersion ve
endpoint, retryOptions, coreRetryOptions, logOptions, clientOptions, httpClient, perCallPolicies,
perRetryPolicies, configuration, audience, LOGGER);

return new AzureQueueStorageImpl(pipeline, endpoint, version.getVersion());
return new AzureQueueStorageImpl(pipeline, endpoint, version);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.storage.queue.implementation;

Expand All @@ -10,18 +10,19 @@
import com.azure.core.http.policy.UserAgentPolicy;
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.SerializerAdapter;
import com.azure.storage.queue.QueueServiceVersion;

/**
* Initializes a new instance of the AzureQueueStorage type.
*/
public final class AzureQueueStorageImpl {
/**
* The URL of the service account, queue or message that is the target of the desired operation.
* The host name of the queue storage account, e.g. accountName.queue.core.windows.net.
*/
private final String url;

Comment thread
ibrandes marked this conversation as resolved.
/**
* Gets The URL of the service account, queue or message that is the target of the desired operation.
* Gets The host name of the queue storage account, e.g. accountName.queue.core.windows.net.
*
* @return the url value.
*/
Expand All @@ -30,17 +31,17 @@ public String getUrl() {
}

/**
* Specifies the version of the operation to use for this request.
* Service version.
*/
private final String version;
private final QueueServiceVersion serviceVersion;

/**
* Gets Specifies the version of the operation to use for this request.
* Gets Service version.
*
* @return the version value.
* @return the serviceVersion value.
*/
public String getVersion() {
return this.version;
public QueueServiceVersion getServiceVersion() {
return this.serviceVersion;
}

/**
Expand Down Expand Up @@ -130,39 +131,39 @@ public MessageIdsImpl getMessageIds() {
/**
* Initializes an instance of AzureQueueStorage client.
*
* @param url The URL of the service account, queue or message that is the target of the desired operation.
* @param version Specifies the version of the operation to use for this request.
* @param url The host name of the queue storage account, e.g. accountName.queue.core.windows.net.
* @param serviceVersion Service version.
*/
public AzureQueueStorageImpl(String url, String version) {
public AzureQueueStorageImpl(String url, QueueServiceVersion serviceVersion) {
this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(),
JacksonAdapter.createDefaultSerializerAdapter(), url, version);
JacksonAdapter.createDefaultSerializerAdapter(), url, serviceVersion);
}

/**
* Initializes an instance of AzureQueueStorage client.
*
* @param httpPipeline The HTTP pipeline to send requests through.
* @param url The URL of the service account, queue or message that is the target of the desired operation.
* @param version Specifies the version of the operation to use for this request.
* @param url The host name of the queue storage account, e.g. accountName.queue.core.windows.net.
* @param serviceVersion Service version.
*/
public AzureQueueStorageImpl(HttpPipeline httpPipeline, String url, String version) {
this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), url, version);
public AzureQueueStorageImpl(HttpPipeline httpPipeline, String url, QueueServiceVersion serviceVersion) {
this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), url, serviceVersion);
}

/**
* Initializes an instance of AzureQueueStorage client.
*
* @param httpPipeline The HTTP pipeline to send requests through.
* @param serializerAdapter The serializer to serialize an object into a string.
* @param url The URL of the service account, queue or message that is the target of the desired operation.
* @param version Specifies the version of the operation to use for this request.
* @param url The host name of the queue storage account, e.g. accountName.queue.core.windows.net.
* @param serviceVersion Service version.
*/
public AzureQueueStorageImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String url,
String version) {
QueueServiceVersion serviceVersion) {
this.httpPipeline = httpPipeline;
this.serializerAdapter = serializerAdapter;
this.url = url;
this.version = version;
this.serviceVersion = serviceVersion;
this.services = new ServicesImpl(this);
this.queues = new QueuesImpl(this);
this.messages = new MessagesImpl(this);
Expand Down
Loading
Loading