diff --git a/storage/client/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageBuilder.java b/storage/client/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageBuilder.java new file mode 100644 index 0000000000000..c77d984c4e928 --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageBuilder.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.storage.blob.implementation; + +import com.azure.core.http.HttpPipeline; +import com.azure.core.implementation.RestProxy; + +/** + * A builder for creating a new instance of the AzureBlobStorage type. + */ +public final class AzureBlobStorageBuilder { + /* + * The URL of the service account, container, or blob that is the targe of the desired operation. + */ + private String url; + + /** + * Sets The URL of the service account, container, or blob that is the targe of the desired operation. + * + * @param url the url value. + * @return the AzureBlobStorageBuilder. + */ + public AzureBlobStorageBuilder url(String url) { + this.url = url; + return this; + } + + /* + * Specifies the version of the operation to use for this request. + */ + private String version; + + /** + * Sets Specifies the version of the operation to use for this request. + * + * @param version the version value. + * @return the AzureBlobStorageBuilder. + */ + public AzureBlobStorageBuilder version(String version) { + this.version = version; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the AzureBlobStorageBuilder. + */ + public AzureBlobStorageBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /** + * Builds an instance of AzureBlobStorageImpl with the provided parameters. + * + * @return an instance of AzureBlobStorageImpl. + */ + public AzureBlobStorageImpl build() { + if (version == null) { + this.version = "2018-11-09"; + } + if (pipeline == null) { + this.pipeline = RestProxy.createDefaultPipeline(); + } + AzureBlobStorageImpl client = new AzureBlobStorageImpl(pipeline); + if (this.url != null) { + client.url(this.url); + } + if (this.version != null) { + client.version(this.version); + } + return client; + } +} diff --git a/storage/client/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageImpl.java b/storage/client/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageImpl.java index 1f54d0ea8e0a7..6702b82da14ea 100644 --- a/storage/client/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageImpl.java +++ b/storage/client/src/main/java/com/azure/storage/blob/implementation/AzureBlobStorageImpl.java @@ -32,7 +32,7 @@ public String url() { * @param url the url value. * @return the service client itself. */ - public AzureBlobStorageImpl withUrl(String url) { + AzureBlobStorageImpl url(String url) { this.url = url; return this; } @@ -57,7 +57,7 @@ public String version() { * @param version the version value. * @return the service client itself. */ - public AzureBlobStorageImpl withVersion(String version) { + AzureBlobStorageImpl version(String version) { this.version = version; return this; } @@ -160,7 +160,6 @@ public AzureBlobStorageImpl() { */ public AzureBlobStorageImpl(HttpPipeline httpPipeline) { super(httpPipeline); - this.version = "2018-11-09"; this.services = new ServicesImpl(this); this.containers = new ContainersImpl(this); this.blobs = new BlobsImpl(this); diff --git a/storage/client/src/main/java/com/azure/storage/file/implementation/AzureFileStorageBuilder.java b/storage/client/src/main/java/com/azure/storage/file/implementation/AzureFileStorageBuilder.java new file mode 100644 index 0000000000000..f00c1c55c9251 --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/file/implementation/AzureFileStorageBuilder.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.storage.file.implementation; + +import com.azure.core.http.HttpPipeline; +import com.azure.core.implementation.RestProxy; + +/** + * A builder for creating a new instance of the AzureFileStorage type. + */ +public final class AzureFileStorageBuilder { + /* + * Specifies the version of the operation to use for this request. + */ + private String version; + + /** + * Sets Specifies the version of the operation to use for this request. + * + * @param version the version value. + * @return the AzureFileStorageBuilder. + */ + public AzureFileStorageBuilder version(String version) { + this.version = version; + return this; + } + + /* + * The URL of the service account, share, directory or file that is the target of the desired operation. + */ + private String url; + + /** + * Sets The URL of the service account, share, directory or file that is the target of the desired operation. + * + * @param url the url value. + * @return the AzureFileStorageBuilder. + */ + public AzureFileStorageBuilder url(String url) { + this.url = url; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the AzureFileStorageBuilder. + */ + public AzureFileStorageBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /** + * Builds an instance of AzureFileStorageImpl with the provided parameters. + * + * @return an instance of AzureFileStorageImpl. + */ + public AzureFileStorageImpl build() { + if (version == null) { + this.version = "2018-11-09"; + } + if (pipeline == null) { + this.pipeline = RestProxy.createDefaultPipeline(); + } + AzureFileStorageImpl client = new AzureFileStorageImpl(pipeline); + if (this.version != null) { + client.version(this.version); + } + if (this.url != null) { + client.url(this.url); + } + return client; + } +} diff --git a/storage/client/src/main/java/com/azure/storage/file/implementation/AzureFileStorageImpl.java b/storage/client/src/main/java/com/azure/storage/file/implementation/AzureFileStorageImpl.java index 44882a3e8a31d..ec39450873537 100644 --- a/storage/client/src/main/java/com/azure/storage/file/implementation/AzureFileStorageImpl.java +++ b/storage/client/src/main/java/com/azure/storage/file/implementation/AzureFileStorageImpl.java @@ -32,7 +32,7 @@ public String version() { * @param version the version value. * @return the service client itself. */ - public AzureFileStorageImpl withVersion(String version) { + AzureFileStorageImpl version(String version) { this.version = version; return this; } @@ -57,7 +57,7 @@ public String url() { * @param url the url value. * @return the service client itself. */ - public AzureFileStorageImpl withUrl(String url) { + AzureFileStorageImpl url(String url) { this.url = url; return this; } @@ -132,7 +132,6 @@ public AzureFileStorageImpl() { */ public AzureFileStorageImpl(HttpPipeline httpPipeline) { super(httpPipeline); - this.version = "2018-11-09"; this.services = new ServicesImpl(this); this.shares = new SharesImpl(this); this.directorys = new DirectorysImpl(this); diff --git a/storage/client/src/main/java/com/azure/storage/queue/QueueAsyncClient.java b/storage/client/src/main/java/com/azure/storage/queue/QueueAsyncClient.java index 0b3cc59af7fd2..90bbb8dbefe66 100644 --- a/storage/client/src/main/java/com/azure/storage/queue/QueueAsyncClient.java +++ b/storage/client/src/main/java/com/azure/storage/queue/QueueAsyncClient.java @@ -2,6 +2,7 @@ import com.azure.core.ServiceClient; import com.azure.core.http.HttpPipeline; +import com.azure.storage.queue.implementation.AzureQueueStorageBuilder; import com.azure.storage.queue.implementation.AzureQueueStorageImpl; import java.net.URL; @@ -14,7 +15,7 @@ public class QueueAsyncClient extends ServiceClient { private QueueAsyncClient(URL endpoint, HttpPipeline httpPipeline) { super(httpPipeline); this.endpoint = endpoint.toString(); - this.generateClient = new AzureQueueStorageImpl(httpPipeline).withUrl(this.endpoint); + this.generateClient = new AzureQueueStorageBuilder().pipeline(httpPipeline).url(this.endpoint).build(); this.apiVersion = this.generateClient.version(); } diff --git a/storage/client/src/main/java/com/azure/storage/queue/implementation/AzureQueueStorageBuilder.java b/storage/client/src/main/java/com/azure/storage/queue/implementation/AzureQueueStorageBuilder.java new file mode 100644 index 0000000000000..9e7205d36c2f7 --- /dev/null +++ b/storage/client/src/main/java/com/azure/storage/queue/implementation/AzureQueueStorageBuilder.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.storage.queue.implementation; + +import com.azure.core.http.HttpPipeline; +import com.azure.core.implementation.RestProxy; + +/** + * A builder for creating a new instance of the AzureQueueStorage type. + */ +public final class AzureQueueStorageBuilder { + /* + * The URL of the service account, queue or message that is the targe of the desired operation. + */ + private String url; + + /** + * Sets The URL of the service account, queue or message that is the targe of the desired operation. + * + * @param url the url value. + * @return the AzureQueueStorageBuilder. + */ + public AzureQueueStorageBuilder url(String url) { + this.url = url; + return this; + } + + /* + * Specifies the version of the operation to use for this request. + */ + private String version; + + /** + * Sets Specifies the version of the operation to use for this request. + * + * @param version the version value. + * @return the AzureQueueStorageBuilder. + */ + public AzureQueueStorageBuilder version(String version) { + this.version = version; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the AzureQueueStorageBuilder. + */ + public AzureQueueStorageBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /** + * Builds an instance of AzureQueueStorageImpl with the provided parameters. + * + * @return an instance of AzureQueueStorageImpl. + */ + public AzureQueueStorageImpl build() { + if (version == null) { + this.version = "2018-03-28"; + } + if (pipeline == null) { + this.pipeline = RestProxy.createDefaultPipeline(); + } + AzureQueueStorageImpl client = new AzureQueueStorageImpl(pipeline); + if (this.url != null) { + client.url(this.url); + } + if (this.version != null) { + client.version(this.version); + } + return client; + } +} diff --git a/storage/client/src/main/java/com/azure/storage/queue/implementation/AzureQueueStorageImpl.java b/storage/client/src/main/java/com/azure/storage/queue/implementation/AzureQueueStorageImpl.java index 354ba1b5e2a0e..1573b9c7e05bd 100644 --- a/storage/client/src/main/java/com/azure/storage/queue/implementation/AzureQueueStorageImpl.java +++ b/storage/client/src/main/java/com/azure/storage/queue/implementation/AzureQueueStorageImpl.java @@ -32,7 +32,7 @@ public String url() { * @param url the url value. * @return the service client itself. */ - public AzureQueueStorageImpl withUrl(String url) { + AzureQueueStorageImpl url(String url) { this.url = url; return this; } @@ -57,7 +57,7 @@ public String version() { * @param version the version value. * @return the service client itself. */ - public AzureQueueStorageImpl withVersion(String version) { + AzureQueueStorageImpl version(String version) { this.version = version; return this; } @@ -132,7 +132,6 @@ public AzureQueueStorageImpl() { */ public AzureQueueStorageImpl(HttpPipeline httpPipeline) { super(httpPipeline); - this.version = "2018-03-28"; this.services = new ServicesImpl(this); this.queues = new QueuesImpl(this); this.messages = new MessagesImpl(this); diff --git a/storage/client/src/test/java/com/azure/storage/blob/BlobPocTests.java b/storage/client/src/test/java/com/azure/storage/blob/BlobPocTests.java index 9aa8fb5e06696..f465b8fc787cb 100644 --- a/storage/client/src/test/java/com/azure/storage/blob/BlobPocTests.java +++ b/storage/client/src/test/java/com/azure/storage/blob/BlobPocTests.java @@ -8,6 +8,7 @@ import com.azure.core.http.HttpPipeline; import com.azure.core.http.ProxyOptions; import com.azure.core.http.ProxyOptions.Type; +import com.azure.storage.blob.implementation.AzureBlobStorageBuilder; import com.azure.storage.blob.implementation.AzureBlobStorageImpl; import com.azure.storage.blob.models.BlobsGetPropertiesResponse; import com.azure.storage.blob.models.BlockLookupList; @@ -27,7 +28,7 @@ public class BlobPocTests { @Test public void testCreateBlob() { - AzureBlobStorageImpl client = new AzureBlobStorageImpl(HttpPipeline.builder().httpClient(HttpClient.createDefault().proxy(() -> new ProxyOptions(Type.HTTP, new InetSocketAddress("localhost", 8888))))/*, + AzureBlobStorageImpl client = new AzureBlobStorageBuilder().pipeline(HttpPipeline.builder().httpClient(HttpClient.createDefault().proxy(() -> new ProxyOptions(Type.HTTP, new InetSocketAddress("localhost", 8888))))/*, new HttpPipelinePolicy() { @Override public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { @@ -44,7 +45,7 @@ public Mono process(HttpPipelineCallContext context, HttpPipelineN } return next.process(); } - }*/.build()).withUrl("https://" + System.getenv("AZURE_STORAGE_ACCOUNT_NAME") + ".blob.core.windows.net/mycontainer/random223" + System.getenv("AZURE_STORAGE_SAS_TOKEN")); + }*/.build()).url("https://" + System.getenv("AZURE_STORAGE_ACCOUNT_NAME") + ".blob.core.windows.net/mycontainer/random223" + System.getenv("AZURE_STORAGE_SAS_TOKEN")).build(); Random random = new Random();